some standalone compile updates for testing

This commit is contained in:
Proddy
2023-12-27 22:41:19 +01:00
parent 23d4f608c5
commit 778bbe3b81
10 changed files with 600 additions and 103 deletions

View File

@@ -2,15 +2,12 @@
#define SecurityManager_h
#include <Arduino.h>
#include <PsychicHttp.h>
#include <Features.h>
#include <list>
#ifndef FACTORY_JWT_SECRET
#define FACTORY_JWT_SECRET ESPUtils::defaultDeviceValue()
#endif
#define FACTORY_JWT_SECRET "secret"
#define ACCESS_TOKEN_PARAMATER "access_token"
#define AUTHORIZATION_HEADER "Authorization"
#define AUTHORIZATION_HEADER_PREFIX "Bearer "
#define AUTHORIZATION_HEADER_PREFIX_LEN 7
@@ -67,10 +64,35 @@ class AuthenticationPredicates {
class SecurityManager {
public:
#if FT_ENABLED(FT_SECURITY)
/*
* Authenticate, returning the user if found
*/
virtual Authentication authenticate(const String & username, const String & password) = 0;
virtual String generateJWT(User * user) = 0;
#endif
/*
* Generate a JWT for the user provided
*/
virtual String generateJWT(User * user) = 0;
/*
* Check the request header for the Authorization token
*/
virtual Authentication authenticateRequest(PsychicRequest * request) = 0;
/**
* Filter a request with the provided predicate, only returning true if the predicate matches.
*/
virtual PsychicRequestFilterFunction filterRequest(AuthenticationPredicate predicate) = 0;
/**
* Wrap the provided request to provide validation against an AuthenticationPredicate.
*/
virtual PsychicHttpRequestCallback wrapRequest(PsychicHttpRequestCallback onRequest, AuthenticationPredicate predicate) = 0;
/**
* Wrap the provided json request callback to provide validation against an AuthenticationPredicate.
*/
virtual PsychicJsonRequestCallback wrapCallback(PsychicJsonRequestCallback onRequest, AuthenticationPredicate predicate) = 0;
};
#endif