#pragma once #include #include "httpd-types.h" #ifndef HTTP_AUTH_REALM #define HTTP_AUTH_REALM "Protected" #endif #define AUTH_MAX_USER_LEN 32 #define AUTH_MAX_PASS_LEN 32 #define AUTH_MAX_TOKEN_LEN 128 /** * Basic auth CGI handler. CGI arg1 is HttpdBasicAuthCb * * @param connData * @return CGI status */ httpd_cgi_state cgiAuthBasic(HttpdConnData *connData); /** * Callback type for basic auth. * * Returns true if the username and password are valid. * The connData pointer can be used to store session data to e.g. make the authorization persistent. */ typedef bool (* HttpdBasicAuthCb)(HttpdConnData *connData, const char *user, const char *password); /** * Bearer auth CGI handler. CGI arg1 is HttpdBearerAuthCb * * @param connData * @return CGI status */ httpd_cgi_state cgiAuthBearer(HttpdConnData *connData); /** * Callback type for bearer auth. * * Returns true if the token is valid. * The connData pointer can be used to store session data to e.g. make the authorization persistent. */ typedef bool (* HttpdBearerAuthCb)(HttpdConnData *connData, const char *token);