blob: 495d240d04fe8a8e73ac8d5f1305c5c49b4fd0b4 [file] [log] [blame]
willy tarreau9e138862006-05-14 23:06:28 +02001/*
2 * URI-based user authentication using the HTTP basic method.
3 *
Willy Tarreauff011f22011-01-06 17:51:27 +01004 * Copyright 2006-2011 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 tarreau1f431b52006-05-21 14:46:15 +020020/* This is a list of proxies we are allowed to see. Later, it should go in the
21 * user list, but before this we need to support de/re-authentication.
22 */
23struct stat_scope {
24 struct stat_scope *next; /* next entry, NULL if none */
25 int px_len; /* proxy name length */
26 char *px_id; /* proxy id */
27};
28
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020029#define ST_HIDEVER 0x00000001 /* do not report the version and reldate */
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020030#define ST_SHNODE 0x00000002 /* show node name */
31#define ST_SHDESC 0x00000004 /* show description */
Krzysztof Piotr Oledzki15f0ac42010-02-22 19:29:40 +010032#define ST_SHLGNDS 0x00000008 /* show legends */
Krzysztof Piotr Oledzki329f74d2010-02-22 20:27:23 +010033#define ST_CONVDONE 0x00000010 /* req_acl conversion done */
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020034
willy tarreau9e138862006-05-14 23:06:28 +020035/* later we may link them to support multiple URI matching */
36struct uri_auth {
37 int uri_len; /* the prefix length */
38 char *uri_prefix; /* the prefix we want to match */
39 char *auth_realm; /* the realm reported to the client */
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020040 char *node, *desc; /* node name & description reported in this stats */
Willy Tarreaubbd42122007-07-25 07:26:38 +020041 int refresh; /* refresh interval for the browser (in seconds) */
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020042 int flags; /* some flags describing the statistics page */
willy tarreau1f431b52006-05-21 14:46:15 +020043 struct stat_scope *scope; /* linked list of authorized proxies */
Krzysztof Piotr Oledzki8c8bd452010-01-29 19:29:32 +010044 struct userlist *userlist; /* private userlist to emulate legacy "stats auth user:password" */
Willy Tarreauff011f22011-01-06 17:51:27 +010045 struct list http_req_rules; /* stats http-request rules : allow/deny/auth */
Cyril Bonté474be412010-10-12 00:14:36 +020046 struct list admin_rules; /* 'stats admin' rules (chained) */
Krzysztof Piotr Oledzki8001d612008-05-31 13:53:23 +020047 struct uri_auth *next; /* Used at deinit() to build a list of unique elements */
willy tarreau9e138862006-05-14 23:06:28 +020048};
49
50/* This is the default statistics URI */
51#ifdef CONFIG_STATS_DEFAULT_URI
52#define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI
53#else
54#define STATS_DEFAULT_URI "/haproxy?stats"
55#endif
56
57/* This is the default statistics realm */
58#ifdef CONFIG_STATS_DEFAULT_REALM
59#define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM
60#else
61#define STATS_DEFAULT_REALM "HAProxy Statistics"
62#endif
63
64
Cyril Bonté474be412010-10-12 00:14:36 +020065struct stats_admin_rule {
66 struct list list; /* list linked to from the proxy */
67 struct acl_cond *cond; /* acl condition to meet */
68};
69
70
willy tarreau9e138862006-05-14 23:06:28 +020071/* Various functions used to set the fields during the configuration parsing.
72 * Please that all those function can initialize the root entry in order not to
73 * force the user to respect a certain order in the configuration file.
74 *
75 * Default values are used during initialization. Check STATS_DEFAULT_* for
76 * more information.
77 */
78struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root);
79struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri);
80struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm);
Willy Tarreaubbd42122007-07-25 07:26:38 +020081struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval);
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +020082struct uri_auth *stats_set_flag(struct uri_auth **root, int flag);
willy tarreau9e138862006-05-14 23:06:28 +020083struct uri_auth *stats_add_auth(struct uri_auth **root, char *user);
willy tarreau1f431b52006-05-21 14:46:15 +020084struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope);
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +020085struct uri_auth *stats_set_node(struct uri_auth **root, char *name);
86struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc);
willy tarreau9e138862006-05-14 23:06:28 +020087
Willy Tarreau2dd0d472006-06-29 17:53:05 +020088#endif /* _COMMON_URI_AUTH_H */
Willy Tarreaubbd42122007-07-25 07:26:38 +020089
90/*
91 * Local variables:
92 * c-indent-level: 8
93 * c-basic-offset: 8
94 * End:
95 */