1 #ifndef HTTP_AUTH_H 2 #define HTTP_AUTH_H 3 4 #include "array-decl.h" 5 6 struct http_auth_param; 7 struct http_auth_challenge; 8 struct http_auth_credentials; 9 10 ARRAY_DEFINE_TYPE(http_auth_param, struct http_auth_param); 11 ARRAY_DEFINE_TYPE(http_auth_challenge, struct http_auth_challenge); 12 13 struct http_auth_param { 14 const char *name; 15 const char *value; 16 }; 17 18 struct http_auth_challenge { 19 const char *scheme; 20 const char *data; 21 ARRAY_TYPE(http_auth_param) params; 22 }; 23 24 struct http_auth_credentials { 25 const char *scheme; 26 const char *data; 27 ARRAY_TYPE(http_auth_param) params; 28 }; 29 30 /* 31 * Parsing 32 */ 33 34 int http_auth_parse_challenges(const unsigned char *data, size_t size, 35 ARRAY_TYPE(http_auth_challenge) *chlngs); 36 int http_auth_parse_credentials(const unsigned char *data, size_t size, 37 struct http_auth_credentials *crdts); 38 39 /* 40 * Construction 41 */ 42 43 void http_auth_create_challenge(string_t *out, 44 const struct http_auth_challenge *chlng); 45 void http_auth_create_challenges(string_t *out, 46 const ARRAY_TYPE(http_auth_challenge) *chlngs); 47 48 void http_auth_create_credentials(string_t *out, 49 const struct http_auth_credentials *crdts); 50 51 /* 52 * Manipulation 53 */ 54 55 void http_auth_challenge_copy(pool_t pool, 56 struct http_auth_challenge *dst, 57 const struct http_auth_challenge *src); 58 struct http_auth_challenge * 59 http_auth_challenge_clone(pool_t pool, 60 const struct http_auth_challenge *src); 61 62 void http_auth_credentials_copy(pool_t pool, 63 struct http_auth_credentials *dst, 64 const struct http_auth_credentials *src); 65 struct http_auth_credentials * 66 http_auth_credentials_clone(pool_t pool, 67 const struct http_auth_credentials *src); 68 69 /* 70 * Simple schemes 71 */ 72 73 void http_auth_basic_challenge_init(struct http_auth_challenge *chlng, 74 const char *realm); 75 void http_auth_basic_credentials_init(struct http_auth_credentials *crdts, 76 const char *username, const char *password); 77 78 #endif 79 80