blob: bb25ac1ea3138aa709f64d32fcfc3c4d6121894d [file] [log] [blame]
willy tarreau9e138862006-05-14 23:06:28 +02001/*
2 * URI-based user authentication using the HTTP basic method.
3 *
Willy Tarreaubaaee002006-06-26 02:48:02 +02004 * Copyright 2006 Willy Tarreau <w@1wt.eu>
willy tarreau9e138862006-05-14 23:06:28 +02005 *
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
Willy Tarreau2dd0d472006-06-29 17:53:05 +020013#ifndef _COMMON_URI_AUTH_H
14#define _COMMON_URI_AUTH_H
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020015
16#include <common/config.h>
17
willy tarreau9e138862006-05-14 23:06:28 +020018/* here we find a very basic list of base64-encoded 'user:passwd' strings */
19struct user_auth {
20 struct user_auth *next; /* next entry, NULL if none */
21 int user_len; /* user:passwd length */
22 char *user_pwd; /* auth as base64("user":"passwd") (see RFC2617) */
23};
24
willy tarreau1f431b52006-05-21 14:46:15 +020025/* This is a list of proxies we are allowed to see. Later, it should go in the
26 * user list, but before this we need to support de/re-authentication.
27 */
28struct stat_scope {
29 struct stat_scope *next; /* next entry, NULL if none */
30 int px_len; /* proxy name length */
31 char *px_id; /* proxy id */
32};
33
willy tarreau9e138862006-05-14 23:06:28 +020034/* later we may link them to support multiple URI matching */
35struct uri_auth {
36 int uri_len; /* the prefix length */
37 char *uri_prefix; /* the prefix we want to match */
38 char *auth_realm; /* the realm reported to the client */
39 struct user_auth *users; /* linked list of valid user:passwd couples */
willy tarreau1f431b52006-05-21 14:46:15 +020040 struct stat_scope *scope; /* linked list of authorized proxies */
willy tarreau9e138862006-05-14 23:06:28 +020041};
42
43/* This is the default statistics URI */
44#ifdef CONFIG_STATS_DEFAULT_URI
45#define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI
46#else
47#define STATS_DEFAULT_URI "/haproxy?stats"
48#endif
49
50/* This is the default statistics realm */
51#ifdef CONFIG_STATS_DEFAULT_REALM
52#define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM
53#else
54#define STATS_DEFAULT_REALM "HAProxy Statistics"
55#endif
56
57
58/* Various functions used to set the fields during the configuration parsing.
59 * Please that all those function can initialize the root entry in order not to
60 * force the user to respect a certain order in the configuration file.
61 *
62 * Default values are used during initialization. Check STATS_DEFAULT_* for
63 * more information.
64 */
65struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root);
66struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri);
67struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm);
68struct uri_auth *stats_add_auth(struct uri_auth **root, char *user);
willy tarreau1f431b52006-05-21 14:46:15 +020069struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope);
willy tarreau9e138862006-05-14 23:06:28 +020070
Willy Tarreau2dd0d472006-06-29 17:53:05 +020071#endif /* _COMMON_URI_AUTH_H */