d73036b2473f0e8da66de699194eacc8e6f7d83a
[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
7 #define APR_WANT_STRFUNC
8 #include "apr_want.h"
9 #include <apr_strings.h>
10 #include <apr_base64.h>
11
12 #include <httpd.h>
13 #include <http_core.h>
14 #include <http_connection.h>
15 #include <http_log.h>
16 #include <http_request.h>
17 #include <mod_session.h>
18 #include <mod_ssl.h>
19
20 /* apache's httpd.h drags in empty PACKAGE_* variables.
21  * undefine them to avoid annoying compile warnings as they
22  * are re-defined in config.h */
23 #undef PACKAGE_BUGREPORT
24 #undef PACKAGE_NAME
25 #undef PACKAGE_STRING
26 #undef PACKAGE_TARNAME
27 #undef PACKAGE_VERSION
28 #include "config.h"
29
30 #include <gssapi/gssapi.h>
31 #include <gssapi/gssapi_ext.h>
32 #include <gssapi/gssapi_krb5.h>
33 #ifdef HAVE_GSSAPI_GSSAPI_NTLMSSP_H
34 #  include <gssapi/gssapi_ntlmssp.h>
35 #endif
36
37 #include "crypto.h"
38 #include "sessions.h"
39
40 #define MIN_SESS_EXP_TIME 300 /* 5 minutes validity minimum */
41
42 #ifdef HAVE_GSS_ACQUIRE_CRED_FROM
43 #  ifdef HAVE_GSS_STORE_CRED_INTO
44 #define HAVE_CRED_STORE 1
45 #  endif
46 #endif
47
48 struct mag_config {
49     apr_pool_t *pool;
50     bool ssl_only;
51     bool map_to_local;
52     bool gss_conn_ctx;
53     bool send_persist;
54     bool use_sessions;
55 #ifdef HAVE_CRED_STORE
56     bool use_s4u2proxy;
57     char *deleg_ccache_dir;
58     gss_key_value_set_desc *cred_store;
59 #endif
60     struct seal_key *mag_skey;
61
62     bool use_basic_auth;
63     gss_OID_set_desc *allowed_mechs;
64     gss_OID_set_desc *basic_mechs;
65 };
66
67 struct mag_server_config {
68     gss_OID_set default_mechs;
69     struct seal_key *mag_skey;
70 };
71
72 struct mag_req_cfg {
73     request_rec *req;
74     struct mag_config *cfg;
75     gss_OID_set desired_mechs;
76     bool use_sessions;
77     bool send_persist;
78     const char *req_proto;
79     const char *rep_proto;
80     struct seal_key *mag_skey;
81 };
82
83 struct mag_conn {
84     apr_pool_t *pool;
85     gss_ctx_id_t ctx;
86     bool established;
87     const char *user_name;
88     const char *gss_name;
89     time_t expiration;
90     int auth_type;
91     bool delegated;
92     struct databuf basic_hash;
93 };
94
95 #define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
96
97 struct mag_conn *mag_new_conn_ctx(apr_pool_t *pool);