willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * URI-based user authentication using the HTTP basic method. |
| 3 | * |
Willy Tarreau | ff011f2 | 2011-01-06 17:51:27 +0100 | [diff] [blame] | 4 | * Copyright 2006-2011 Willy Tarreau <w@1wt.eu> |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 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 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 13 | #ifndef _COMMON_URI_AUTH_H |
| 14 | #define _COMMON_URI_AUTH_H |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 15 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 16 | |
Willy Tarreau | 4c7e4b7 | 2020-05-27 12:58:42 +0200 | [diff] [blame] | 17 | #include <haproxy/api.h> |
Krzysztof Piotr Oledzki | 9610504 | 2010-01-29 17:50:44 +0100 | [diff] [blame] | 18 | #include <types/auth.h> |
| 19 | |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 20 | /* 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 | */ |
| 23 | struct 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 | |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 29 | /* later we may link them to support multiple URI matching */ |
| 30 | struct uri_auth { |
| 31 | int uri_len; /* the prefix length */ |
| 32 | char *uri_prefix; /* the prefix we want to match */ |
| 33 | char *auth_realm; /* the realm reported to the client */ |
Krzysztof Piotr Oledzki | 48cb2ae | 2009-10-02 22:51:14 +0200 | [diff] [blame] | 34 | char *node, *desc; /* node name & description reported in this stats */ |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 35 | int refresh; /* refresh interval for the browser (in seconds) */ |
Willy Tarreau | 708c416 | 2019-10-09 10:19:16 +0200 | [diff] [blame] | 36 | unsigned int flags; /* STAT_* flags from stats.h and for applet.ctx.stats.flags */ |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 37 | struct stat_scope *scope; /* linked list of authorized proxies */ |
Krzysztof Piotr Oledzki | 8c8bd45 | 2010-01-29 19:29:32 +0100 | [diff] [blame] | 38 | struct userlist *userlist; /* private userlist to emulate legacy "stats auth user:password" */ |
Willy Tarreau | ff011f2 | 2011-01-06 17:51:27 +0100 | [diff] [blame] | 39 | struct list http_req_rules; /* stats http-request rules : allow/deny/auth */ |
Cyril Bonté | 474be41 | 2010-10-12 00:14:36 +0200 | [diff] [blame] | 40 | struct list admin_rules; /* 'stats admin' rules (chained) */ |
Krzysztof Piotr Oledzki | 8001d61 | 2008-05-31 13:53:23 +0200 | [diff] [blame] | 41 | struct uri_auth *next; /* Used at deinit() to build a list of unique elements */ |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | /* This is the default statistics URI */ |
| 45 | #ifdef CONFIG_STATS_DEFAULT_URI |
| 46 | #define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI |
| 47 | #else |
| 48 | #define STATS_DEFAULT_URI "/haproxy?stats" |
| 49 | #endif |
| 50 | |
| 51 | /* This is the default statistics realm */ |
| 52 | #ifdef CONFIG_STATS_DEFAULT_REALM |
| 53 | #define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM |
| 54 | #else |
| 55 | #define STATS_DEFAULT_REALM "HAProxy Statistics" |
| 56 | #endif |
| 57 | |
| 58 | |
Cyril Bonté | 474be41 | 2010-10-12 00:14:36 +0200 | [diff] [blame] | 59 | struct stats_admin_rule { |
| 60 | struct list list; /* list linked to from the proxy */ |
| 61 | struct acl_cond *cond; /* acl condition to meet */ |
| 62 | }; |
| 63 | |
| 64 | |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 65 | /* Various functions used to set the fields during the configuration parsing. |
| 66 | * Please that all those function can initialize the root entry in order not to |
| 67 | * force the user to respect a certain order in the configuration file. |
| 68 | * |
| 69 | * Default values are used during initialization. Check STATS_DEFAULT_* for |
| 70 | * more information. |
| 71 | */ |
| 72 | struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root); |
| 73 | struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri); |
| 74 | struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm); |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 75 | struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval); |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 76 | struct uri_auth *stats_set_flag(struct uri_auth **root, int flag); |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 77 | struct uri_auth *stats_add_auth(struct uri_auth **root, char *user); |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 78 | struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope); |
Krzysztof Piotr Oledzki | 48cb2ae | 2009-10-02 22:51:14 +0200 | [diff] [blame] | 79 | struct uri_auth *stats_set_node(struct uri_auth **root, char *name); |
| 80 | struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc); |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 81 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 82 | #endif /* _COMMON_URI_AUTH_H */ |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 83 | |
| 84 | /* |
| 85 | * Local variables: |
| 86 | * c-indent-level: 8 |
| 87 | * c-basic-offset: 8 |
| 88 | * End: |
| 89 | */ |