2019-05-18 18:35:27 +00:00
|
|
|
#ifndef AuthenticationService_H_
|
|
|
|
#define AuthenticationService_H_
|
|
|
|
|
|
|
|
#include <SecurityManager.h>
|
2019-05-29 22:48:16 +00:00
|
|
|
#include <ESPAsyncWebServer.h>
|
|
|
|
#include <AsyncJsonWebHandler.h>
|
|
|
|
#include <AsyncArduinoJson6.h>
|
2019-05-18 18:35:27 +00:00
|
|
|
|
|
|
|
#define VERIFY_AUTHORIZATION_PATH "/rest/verifyAuthorization"
|
|
|
|
#define SIGN_IN_PATH "/rest/signIn"
|
|
|
|
|
|
|
|
#define MAX_AUTHENTICATION_SIZE 256
|
|
|
|
|
|
|
|
class AuthenticationService {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-07-14 21:13:26 +00:00
|
|
|
AuthenticationService(SecurityManager* securityManager);
|
2019-05-18 18:35:27 +00:00
|
|
|
~AuthenticationService();
|
|
|
|
|
2019-07-14 21:13:26 +00:00
|
|
|
void init(AsyncWebServer* server);
|
|
|
|
|
2019-05-18 18:35:27 +00:00
|
|
|
private:
|
|
|
|
// server instance
|
|
|
|
AsyncWebServer* _server;
|
|
|
|
SecurityManager* _securityManager;
|
|
|
|
AsyncJsonWebHandler _signInHandler;
|
|
|
|
|
|
|
|
// endpoint functions
|
|
|
|
void signIn(AsyncWebServerRequest *request, JsonDocument &jsonDocument);
|
|
|
|
void verifyAuthorization(AsyncWebServerRequest *request);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // end SecurityManager_h
|