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 | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 4 | * Copyright 2006-2007 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 | |
| 16 | #include <common/config.h> |
| 17 | |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 18 | /* here we find a very basic list of base64-encoded 'user:passwd' strings */ |
| 19 | struct 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 tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 25 | /* 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 | */ |
| 28 | struct 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 | |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 34 | #define ST_HIDEVER 0x00000001 /* do not report the version and reldate */ |
| 35 | |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 36 | /* later we may link them to support multiple URI matching */ |
| 37 | struct uri_auth { |
| 38 | int uri_len; /* the prefix length */ |
| 39 | char *uri_prefix; /* the prefix we want to match */ |
| 40 | char *auth_realm; /* the realm reported to the client */ |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 41 | int refresh; /* refresh interval for the browser (in seconds) */ |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 42 | int flags; /* some flags describing the statistics page */ |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 43 | struct user_auth *users; /* linked list of valid user:passwd couples */ |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 44 | struct stat_scope *scope; /* linked list of authorized proxies */ |
Krzysztof Piotr Oledzki | 8001d61 | 2008-05-31 13:53:23 +0200 | [diff] [blame] | 45 | 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] | 46 | }; |
| 47 | |
| 48 | /* This is the default statistics URI */ |
| 49 | #ifdef CONFIG_STATS_DEFAULT_URI |
| 50 | #define STATS_DEFAULT_URI CONFIG_STATS_DEFAULT_URI |
| 51 | #else |
| 52 | #define STATS_DEFAULT_URI "/haproxy?stats" |
| 53 | #endif |
| 54 | |
| 55 | /* This is the default statistics realm */ |
| 56 | #ifdef CONFIG_STATS_DEFAULT_REALM |
| 57 | #define STATS_DEFAULT_REALM CONFIG_STATS_DEFAULT_REALM |
| 58 | #else |
| 59 | #define STATS_DEFAULT_REALM "HAProxy Statistics" |
| 60 | #endif |
| 61 | |
| 62 | |
| 63 | /* Various functions used to set the fields during the configuration parsing. |
| 64 | * Please that all those function can initialize the root entry in order not to |
| 65 | * force the user to respect a certain order in the configuration file. |
| 66 | * |
| 67 | * Default values are used during initialization. Check STATS_DEFAULT_* for |
| 68 | * more information. |
| 69 | */ |
| 70 | struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root); |
| 71 | struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri); |
| 72 | struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm); |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 73 | struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval); |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 74 | struct uri_auth *stats_set_flag(struct uri_auth **root, int flag); |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 75 | struct uri_auth *stats_add_auth(struct uri_auth **root, char *user); |
willy tarreau | 1f431b5 | 2006-05-21 14:46:15 +0200 | [diff] [blame] | 76 | struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope); |
willy tarreau | 9e13886 | 2006-05-14 23:06:28 +0200 | [diff] [blame] | 77 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 78 | #endif /* _COMMON_URI_AUTH_H */ |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 79 | |
| 80 | /* |
| 81 | * Local variables: |
| 82 | * c-indent-level: 8 |
| 83 | * c-basic-offset: 8 |
| 84 | * End: |
| 85 | */ |