2005-02-20 14:27:00 +00:00
|
|
|
#ifndef _HTTP_AUTH_H_
|
|
|
|
#define _HTTP_AUTH_H_
|
2016-03-19 15:14:35 +00:00
|
|
|
#include "first.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "base_decls.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "array.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2017-01-24 02:01:58 +00:00
|
|
|
void http_auth_dumbdata_reset (void);
|
|
|
|
|
2019-03-04 00:00:59 +00:00
|
|
|
typedef enum http_auth_digest_type {
|
|
|
|
HTTP_AUTH_DIGEST_NONE = 0
|
|
|
|
,HTTP_AUTH_DIGEST_SESS = 0x01
|
|
|
|
,HTTP_AUTH_DIGEST_MD5 = 0x02
|
|
|
|
,HTTP_AUTH_DIGEST_SHA256 = 0x04
|
|
|
|
,HTTP_AUTH_DIGEST_SHA512_256 = 0x08
|
|
|
|
} http_auth_digest_type;
|
|
|
|
|
|
|
|
#define HTTP_AUTH_DIGEST_MD5_BINLEN 16 /* MD5_DIGEST_LENGTH */
|
|
|
|
#define HTTP_AUTH_DIGEST_SHA256_BINLEN 32 /* SHA256_DIGEST_LENGTH */
|
|
|
|
#define HTTP_AUTH_DIGEST_SHA512_256_BINLEN 32 /* SHA512_256_DIGEST_LENGTH */
|
|
|
|
|
|
|
|
unsigned int http_auth_digest_len (int algo);
|
|
|
|
|
2016-09-16 20:04:39 +00:00
|
|
|
struct http_auth_scheme_t;
|
|
|
|
struct http_auth_require_t;
|
|
|
|
struct http_auth_backend_t;
|
|
|
|
|
|
|
|
typedef struct http_auth_require_t {
|
|
|
|
const struct http_auth_scheme_t *scheme;
|
2019-11-22 05:22:01 +00:00
|
|
|
const buffer *realm;
|
2020-02-04 02:08:34 +00:00
|
|
|
const buffer *nonce_secret;
|
2016-09-16 20:04:39 +00:00
|
|
|
int valid_user;
|
2019-03-04 00:00:59 +00:00
|
|
|
int algorithm;
|
2019-11-22 05:22:01 +00:00
|
|
|
array user;
|
|
|
|
array group;
|
|
|
|
array host;
|
2016-09-16 20:04:39 +00:00
|
|
|
} http_auth_require_t;
|
|
|
|
|
|
|
|
http_auth_require_t * http_auth_require_init (void);
|
|
|
|
void http_auth_require_free (http_auth_require_t *require);
|
|
|
|
int http_auth_match_rules (const http_auth_require_t *require, const char *user, const char *group, const char *host);
|
|
|
|
|
2019-03-04 00:00:59 +00:00
|
|
|
typedef struct http_auth_info_t {
|
|
|
|
int dalgo;
|
|
|
|
unsigned int dlen;
|
|
|
|
const char *username;
|
|
|
|
size_t ulen;
|
|
|
|
const char *realm;
|
|
|
|
size_t rlen;
|
|
|
|
/*(must be >= largest binary digest length accepted above)*/
|
|
|
|
unsigned char digest[32];
|
|
|
|
} http_auth_info_t;
|
|
|
|
|
2016-08-18 17:54:53 +00:00
|
|
|
typedef struct http_auth_backend_t {
|
|
|
|
const char *name;
|
2020-01-13 02:51:12 +00:00
|
|
|
handler_t(*basic)(request_st *r, void *p_d, const http_auth_require_t *require, const buffer *username, const char *pw);
|
|
|
|
handler_t(*digest)(request_st *r, void *p_d, http_auth_info_t *ai);
|
2016-08-18 17:54:53 +00:00
|
|
|
void *p_d;
|
|
|
|
} http_auth_backend_t;
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2016-09-16 20:04:39 +00:00
|
|
|
typedef struct http_auth_scheme_t {
|
|
|
|
const char *name;
|
2020-01-13 02:51:12 +00:00
|
|
|
handler_t(*checkfn)(request_st *r, void *p_d, const struct http_auth_require_t *require, const struct http_auth_backend_t *backend);
|
2016-09-16 20:04:39 +00:00
|
|
|
/*(backend is arg only because auth.backend is separate config directive)*/
|
|
|
|
void *p_d;
|
|
|
|
} http_auth_scheme_t;
|
|
|
|
|
|
|
|
const http_auth_scheme_t * http_auth_scheme_get (const buffer *name);
|
|
|
|
void http_auth_scheme_set (const http_auth_scheme_t *scheme);
|
2016-08-18 17:54:53 +00:00
|
|
|
const http_auth_backend_t * http_auth_backend_get (const buffer *name);
|
|
|
|
void http_auth_backend_set (const http_auth_backend_t *backend);
|
2019-09-08 22:25:39 +00:00
|
|
|
|
2019-09-08 22:26:58 +00:00
|
|
|
__attribute_pure__
|
|
|
|
int http_auth_const_time_memeq (const void *a, const void *b, size_t len);
|
|
|
|
|
2019-09-08 22:25:39 +00:00
|
|
|
__attribute_pure__
|
|
|
|
int http_auth_const_time_memeq_pad (const void *a, size_t alen, const void *b, size_t blen);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2020-01-13 02:51:12 +00:00
|
|
|
void http_auth_setenv(request_st *r, const char *username, size_t ulen, const char *auth_type, size_t alen);
|
2016-09-16 20:04:39 +00:00
|
|
|
|
2019-03-03 22:55:04 +00:00
|
|
|
int http_auth_digest_hex2bin (const char *hexstr, size_t len, unsigned char *bin, size_t binlen);
|
2016-09-10 02:28:01 +00:00
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#endif
|