willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 1 | /* |
| 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 */ |
| 16 | struct 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 | |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 22 | /* This is a list of proxies we are allowed to see. Later, it should go in the |
| 23 | * user list, but before this we need to support de/re-authentication. |
| 24 | */ |
| 25 | struct stat_scope { |
| 26 | struct stat_scope *next; /* next entry, NULL if none */ |
| 27 | int px_len; /* proxy name length */ |
| 28 | char *px_id; /* proxy id */ |
| 29 | }; |
| 30 | |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 31 | /* later we may link them to support multiple URI matching */ |
| 32 | struct uri_auth { |
| 33 | int uri_len; /* the prefix length */ |
| 34 | char *uri_prefix; /* the prefix we want to match */ |
| 35 | char *auth_realm; /* the realm reported to the client */ |
| 36 | struct user_auth *users; /* linked list of valid user:passwd couples */ |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 37 | struct stat_scope *scope; /* linked list of authorized proxies */ |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | /* This is the default statistics URI */ |
| 41 | #ifdef CONFIG_STATS_DEFAULT_URI |
| 42 | #define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI |
| 43 | #else |
| 44 | #define STATS_DEFAULT_URI "/haproxy?stats" |
| 45 | #endif |
| 46 | |
| 47 | /* This is the default statistics realm */ |
| 48 | #ifdef CONFIG_STATS_DEFAULT_REALM |
| 49 | #define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM |
| 50 | #else |
| 51 | #define STATS_DEFAULT_REALM "HAProxy Statistics" |
| 52 | #endif |
| 53 | |
| 54 | |
| 55 | /* Various functions used to set the fields during the configuration parsing. |
| 56 | * Please that all those function can initialize the root entry in order not to |
| 57 | * force the user to respect a certain order in the configuration file. |
| 58 | * |
| 59 | * Default values are used during initialization. Check STATS_DEFAULT_* for |
| 60 | * more information. |
| 61 | */ |
| 62 | struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root); |
| 63 | struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri); |
| 64 | struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm); |
| 65 | struct uri_auth *stats_add_auth(struct uri_auth **root, char *user); |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 66 | struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope); |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 67 | |
| 68 | #endif /* URI_AUTH_H */ |