5662add686a45875e44b7813ae6d907f7a27fa22
[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 #include "environ.h"
40
41 #define MIN_SESS_EXP_TIME 300 /* 5 minutes validity minimum */
42
43 #ifdef HAVE_GSS_ACQUIRE_CRED_FROM
44 #  ifdef HAVE_GSS_STORE_CRED_INTO
45 #define HAVE_CRED_STORE 1
46 #  endif
47 #endif
48
49 struct mag_config {
50     apr_pool_t *pool;
51     bool ssl_only;
52     bool map_to_local;
53     bool gss_conn_ctx;
54     bool send_persist;
55     bool use_sessions;
56 #ifdef HAVE_CRED_STORE
57     bool use_s4u2proxy;
58     char *deleg_ccache_dir;
59     gss_key_value_set_desc *cred_store;
60 #endif
61     struct seal_key *mag_skey;
62
63     bool use_basic_auth;
64     gss_OID_set_desc *allowed_mechs;
65     gss_OID_set_desc *basic_mechs;
66 };
67
68 struct mag_server_config {
69     gss_OID_set default_mechs;
70     struct seal_key *mag_skey;
71 };
72
73 struct mag_req_cfg {
74     request_rec *req;
75     struct mag_config *cfg;
76     gss_OID_set desired_mechs;
77     bool use_sessions;
78     bool send_persist;
79     const char *req_proto;
80     const char *rep_proto;
81     struct seal_key *mag_skey;
82 };
83
84 struct mag_conn {
85     apr_pool_t *pool;
86     gss_ctx_id_t ctx;
87     bool established;
88     const char *user_name;
89     const char *gss_name;
90     time_t expiration;
91     int auth_type;
92     bool delegated;
93     struct databuf basic_hash;
94     bool is_preserved;
95 };
96
97 #define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
98
99 struct mag_conn *mag_new_conn_ctx(apr_pool_t *pool);
100 const char *mag_str_auth_type(int auth_type);
101 char *mag_gss_name_to_ccache_name(request_rec *req,
102                                   char *dir, const char *gss_name);