blob: f7ff6c8b8a8cd4bf678ae4b382ec640c884f2a2e [file] [log] [blame]
willy tarreau9e138862006-05-14 23:06:28 +02001/*
2 * URI-based user authentication using the HTTP basic method.
3 *
4 * Copyright 2006 Willy Tarreau <willy@w.ods.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#ifndef URI_AUTH_H
14#define URI_AUTH_H
15/* here we find a very basic list of base64-encoded 'user:passwd' strings */
16struct user_auth {
17 struct user_auth *next; /* next entry, NULL if none */
18 int user_len; /* user:passwd length */
19 char *user_pwd; /* auth as base64("user":"passwd") (see RFC2617) */
20};
21
22/* later we may link them to support multiple URI matching */
23struct uri_auth {
24 int uri_len; /* the prefix length */
25 char *uri_prefix; /* the prefix we want to match */
26 char *auth_realm; /* the realm reported to the client */
27 struct user_auth *users; /* linked list of valid user:passwd couples */
28};
29
30/* This is the default statistics URI */
31#ifdef CONFIG_STATS_DEFAULT_URI
32#define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI
33#else
34#define STATS_DEFAULT_URI "/haproxy?stats"
35#endif
36
37/* This is the default statistics realm */
38#ifdef CONFIG_STATS_DEFAULT_REALM
39#define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM
40#else
41#define STATS_DEFAULT_REALM "HAProxy Statistics"
42#endif
43
44
45/* Various functions used to set the fields during the configuration parsing.
46 * Please that all those function can initialize the root entry in order not to
47 * force the user to respect a certain order in the configuration file.
48 *
49 * Default values are used during initialization. Check STATS_DEFAULT_* for
50 * more information.
51 */
52struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root);
53struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri);
54struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm);
55struct uri_auth *stats_add_auth(struct uri_auth **root, char *user);
56
57#endif /* URI_AUTH_H */