blob: b4c297c77511be17330e6cd32d7c33aee6d9d78b [file] [log] [blame]
willy tarreau9e138862006-05-14 23:06:28 +02001/*
2 * URI-based user authentication using the HTTP basic method.
3 *
Willy Tarreaubbd42122007-07-25 07:26:38 +02004 * Copyright 2006-2007 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
Krzysztof Piotr Oledzki96105042010-01-29 17:50:44 +010018#include <types/auth.h>
19
willy tarreau9e138862006-05-14 23:06:28 +020020/* here we find a very basic list of base64-encoded 'user:passwd' strings */
21struct user_auth {
22 struct user_auth *next; /* next entry, NULL if none */
23 int user_len; /* user:passwd length */
24 char *user_pwd; /* auth as base64("user":"passwd") (see RFC2617) */
25};
26
willy tarreau1f431b52006-05-21 14:46:15 +020027/* This is a list of proxies we are allowed to see. Later, it should go in the
28 * user list, but before this we need to support de/re-authentication.
29 */
30struct stat_scope {
31 struct stat_scope *next; /* next entry, NULL if none */
32 int px_len; /* proxy name length */
33 char *px_id; /* proxy id */
34};
35
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020036#define ST_HIDEVER 0x00000001 /* do not report the version and reldate */
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020037#define ST_SHNODE 0x00000002 /* show node name */
38#define ST_SHDESC 0x00000004 /* show description */
Krzysztof Piotr Oledzki15514c22010-01-04 16:03:09 +010039#define ST_SHLGNDS 0x0000008 /* show legends */
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020040
willy tarreau9e138862006-05-14 23:06:28 +020041/* later we may link them to support multiple URI matching */
42struct uri_auth {
43 int uri_len; /* the prefix length */
44 char *uri_prefix; /* the prefix we want to match */
45 char *auth_realm; /* the realm reported to the client */
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020046 char *node, *desc; /* node name & description reported in this stats */
Willy Tarreaubbd42122007-07-25 07:26:38 +020047 int refresh; /* refresh interval for the browser (in seconds) */
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020048 int flags; /* some flags describing the statistics page */
willy tarreau9e138862006-05-14 23:06:28 +020049 struct user_auth *users; /* linked list of valid user:passwd couples */
willy tarreau1f431b52006-05-21 14:46:15 +020050 struct stat_scope *scope; /* linked list of authorized proxies */
Krzysztof Piotr Oledzki96105042010-01-29 17:50:44 +010051 struct list req_acl; /* */
Krzysztof Piotr Oledzki8001d612008-05-31 13:53:23 +020052 struct uri_auth *next; /* Used at deinit() to build a list of unique elements */
willy tarreau9e138862006-05-14 23:06:28 +020053};
54
55/* This is the default statistics URI */
56#ifdef CONFIG_STATS_DEFAULT_URI
57#define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI
58#else
59#define STATS_DEFAULT_URI "/haproxy?stats"
60#endif
61
62/* This is the default statistics realm */
63#ifdef CONFIG_STATS_DEFAULT_REALM
64#define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM
65#else
66#define STATS_DEFAULT_REALM "HAProxy Statistics"
67#endif
68
69
70/* Various functions used to set the fields during the configuration parsing.
71 * Please that all those function can initialize the root entry in order not to
72 * force the user to respect a certain order in the configuration file.
73 *
74 * Default values are used during initialization. Check STATS_DEFAULT_* for
75 * more information.
76 */
77struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root);
78struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri);
79struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm);
Willy Tarreaubbd42122007-07-25 07:26:38 +020080struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval);
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020081struct uri_auth *stats_set_flag(struct uri_auth **root, int flag);
willy tarreau9e138862006-05-14 23:06:28 +020082struct uri_auth *stats_add_auth(struct uri_auth **root, char *user);
willy tarreau1f431b52006-05-21 14:46:15 +020083struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope);
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020084struct uri_auth *stats_set_node(struct uri_auth **root, char *name);
85struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc);
willy tarreau9e138862006-05-14 23:06:28 +020086
Willy Tarreau2dd0d472006-06-29 17:53:05 +020087#endif /* _COMMON_URI_AUTH_H */
Willy Tarreaubbd42122007-07-25 07:26:38 +020088
89/*
90 * Local variables:
91 * c-indent-level: 8
92 * c-basic-offset: 8
93 * End:
94 */