Optimize BASIC AUTH checks with sessions.
[mod_auth_gssapi.git] / src / mod_auth_gssapi.h
1 /* Copyright (C) 2014 mod_auth_gssapi authors - See COPYING for (C) terms */
2
3 #include <stdbool.h>
4 #include <stdint.h>
5 #include <time.h>
6 #include <gssapi/gssapi.h>
7 #include <gssapi/gssapi_ext.h>
8 #include <gssapi/gssapi_krb5.h>
9 #include <gssapi/gssapi_ntlmssp.h>
10
11 #define APR_WANT_STRFUNC
12 #include "apr_want.h"
13 #include <apr_strings.h>
14 #include <apr_base64.h>
15
16 #include <httpd.h>
17 #include <http_core.h>
18 #include <http_connection.h>
19 #include <http_log.h>
20 #include <http_request.h>
21 #include <mod_session.h>
22 #include <mod_ssl.h>
23
24 /* apache's httpd.h drags in empty PACKAGE_* variables.
25  * undefine them to avoid annoying compile warnings as they
26  * are re-defined in config.h */
27 #undef PACKAGE_BUGREPORT
28 #undef PACKAGE_NAME
29 #undef PACKAGE_STRING
30 #undef PACKAGE_TARNAME
31 #undef PACKAGE_VERSION
32 #include "config.h"
33
34 #include "crypto.h"
35 #include "sessions.h"
36
37 #define MIN_SESS_EXP_TIME 300 /* 5 minutes validity minimum */
38
39 #ifdef HAVE_GSS_ACQUIRE_CRED_FROM
40 #  ifdef HAVE_GSS_STORE_CRED_INTO
41 #define HAVE_CRED_STORE 1
42 #  endif
43 #endif
44
45 struct mag_config {
46     apr_pool_t *pool;
47     bool ssl_only;
48     bool map_to_local;
49     bool gss_conn_ctx;
50     bool send_persist;
51     bool use_sessions;
52 #ifdef HAVE_CRED_STORE
53     bool use_s4u2proxy;
54     char *deleg_ccache_dir;
55     gss_key_value_set_desc *cred_store;
56 #endif
57     struct seal_key *mag_skey;
58     bool use_basic_auth;
59     gss_OID_set_desc *allowed_mechs;
60 };
61
62 struct mag_conn {
63     apr_pool_t *parent;
64     gss_ctx_id_t ctx;
65     bool established;
66     const char *user_name;
67     const char *gss_name;
68     time_t expiration;
69     int auth_type;
70     bool delegated;
71     struct databuf basic_hash;
72 };
73
74 #define discard_const(ptr) ((void *)((uintptr_t)(ptr)))