SpriteHTTPD - embedded HTTP server with read-only filesystem and templating, originally developed for ESP8266, now stand-alone and POSIX compatible.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
spritehttpd/spritehttpd/include/httpd-auth.h

44 lines
1.1 KiB

#pragma once
#include <stdbool.h>
#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);