2 * Daniel Kouril <kouril@users.sourceforge.net>
4 * Source and Documentation can be found at:
5 * http://modauthkerb.sourceforge.net/
8 * James E. Robinson, III <james@ncstate.net>
9 * Daniel Henninger <daniel@ncsu.edu>
10 * Ludek Sulak <xsulak@fi.muni.cz>
14 * Copyright (c) 2004-2005 Masarykova universita
15 * (Masaryk University, Brno, Czech Republic)
16 * All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are met:
21 * 1. Redistributions of source code must retain the above copyright notice,
22 * this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
28 * 3. Neither the name of the University nor the names of its contributors may
29 * be used to endorse or promote products derived from this software
30 * without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
36 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGE.
53 #define MODAUTHKERB_VERSION "5.0-rc6"
55 #define MECH_NEGOTIATE "Negotiate"
56 #define SERVICE_NAME "HTTP"
59 #include <http_config.h>
60 #include <http_core.h>
62 #include <http_protocol.h>
63 #include <http_request.h>
65 #ifdef STANDARD20_MODULE_STUFF
66 #include <apr_strings.h>
67 #include <apr_base64.h>
69 #define ap_null_cleanup NULL
70 #define ap_register_cleanup apr_pool_cleanup_register
72 #define ap_pstrdup apr_pstrdup
73 #define ap_pstrcat apr_pstrcat
74 #define ap_pcalloc apr_pcalloc
75 #define ap_psprintf apr_psprintf
77 #define ap_base64decode_len apr_base64_decode_len
78 #define ap_base64decode apr_base64_decode
79 #define ap_base64encode_len apr_base64_encode_len
80 #define ap_base64encode apr_base64_encode
82 #define ap_table_setn apr_table_setn
83 #define ap_table_add apr_table_add
85 #define ap_pstrchr_c strchr
86 #endif /* STANDARD20_MODULE_STUFF */
89 #define vsnprintf _vsnprintf
90 #define snprintf _snprintf
98 # include <gssapi/gssapi.h>
99 # include <gssapi/gssapi_generic.h>
100 # include <gssapi/gssapi_krb5.h>
101 # define GSS_C_NT_USER_NAME gss_nt_user_name
102 # define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
103 # define krb5_get_err_text(context,code) error_message(code)
105 #ifndef GSSAPI_SUPPORTS_SPNEGO
106 # include "spnegokrb5.h"
111 /* Prevent warning about closesocket redefinition (Apache's ap_config.h and
112 * MIT Kerberos' port-sockets.h both define it as close) */
117 #include <netdb.h> /* gethostbyname() */
121 /* should be HAVE_UNISTD_H instead */
125 #ifdef STANDARD20_MODULE_STUFF
126 module AP_MODULE_DECLARE_DATA auth_kerb_module;
128 module auth_kerb_module;
131 /***************************************************************************
132 Macros To Ease Compatibility
133 ***************************************************************************/
134 #ifdef STANDARD20_MODULE_STUFF
135 #define MK_POOL apr_pool_t
136 #define MK_TABLE_GET apr_table_get
137 #define MK_USER r->user
138 #define MK_AUTH_TYPE r->ap_auth_type
141 #define MK_TABLE_GET ap_table_get
142 #define MK_USER r->connection->user
143 #define MK_AUTH_TYPE r->connection->ap_auth_type
144 #define PROXYREQ_PROXY STD_PROXY
147 /***************************************************************************
148 Auth Configuration Structure
149 ***************************************************************************/
151 char *krb_auth_realms;
152 int krb_save_credentials;
154 const char *krb_service_name;
155 int krb_authoritative;
156 int krb_delegate_basic;
157 int krb_ssl_preauthentication;
160 int krb_method_gssapi;
161 int krb_method_k5pass;
165 int krb_method_k4pass;
170 set_kerb_auth_headers(request_rec *r, const kerb_auth_config *conf,
171 int use_krb4, int use_krb5pwd, char *negotiate_ret_value);
174 krb5_save_realms(cmd_parms *cmd, void *sec, const char *arg);
176 #ifdef STANDARD20_MODULE_STUFF
177 #define command(name, func, var, type, usage) \
178 AP_INIT_ ## type (name, (void*) func, \
179 (void*)APR_OFFSETOF(kerb_auth_config, var), \
180 OR_AUTHCFG | RSRC_CONF, usage)
182 #define command(name, func, var, type, usage) \
184 (void*)XtOffsetOf(kerb_auth_config, var), \
185 OR_AUTHCFG | RSRC_CONF, type, usage }
188 static const command_rec kerb_auth_cmds[] = {
189 command("KrbAuthRealms", krb5_save_realms, krb_auth_realms,
190 RAW_ARGS, "Realms to attempt authentication against (can be multiple)."),
192 command("KrbAuthRealm", krb5_save_realms, krb_auth_realms,
193 RAW_ARGS, "Alias for KrbAuthRealms."),
195 command("KrbSaveCredentials", ap_set_flag_slot, krb_save_credentials,
196 FLAG, "Save and store credentials/tickets retrieved during auth."),
198 command("KrbVerifyKDC", ap_set_flag_slot, krb_verify_kdc,
199 FLAG, "Verify tickets against keytab to prevent KDC spoofing attacks."),
201 command("KrbServiceName", ap_set_string_slot, krb_service_name,
202 TAKE1, "Full or partial service name to be used by Apache for authentication."),
204 command("KrbAuthoritative", ap_set_flag_slot, krb_authoritative,
205 FLAG, "Set to 'off' to allow access control to be passed along to lower modules iff the UserID is not known to this module."),
207 command("KrbDelegateBasic", ap_set_flag_slot, krb_delegate_basic,
208 FLAG, "Always offer Basic authentication regardless of KrbMethodK5Pass and pass on authentication to lower modules if Basic headers arrive."),
210 command("KrbEnableSSLPreauthentication", ap_set_flag_slot, krb_ssl_preauthentication,
211 FLAG, "Don't do Kerberos authentication if the user is already authenticated using SSL and her client certificate."),
214 command("Krb5Keytab", ap_set_file_slot, krb_5_keytab,
215 TAKE1, "Location of Kerberos V5 keytab file."),
217 command("KrbMethodNegotiate", ap_set_flag_slot, krb_method_gssapi,
218 FLAG, "Enable Negotiate authentication method."),
220 command("KrbMethodK5Passwd", ap_set_flag_slot, krb_method_k5pass,
221 FLAG, "Enable Kerberos V5 password authentication."),
225 command("Krb4Srvtab", ap_set_file_slot, krb_4_srvtab,
226 TAKE1, "Location of Kerberos V4 srvtab file."),
228 command("KrbMethodK4Passwd", ap_set_flag_slot, krb_method_k4pass,
229 FLAG, "Enable Kerberos V4 password authentication."),
237 mkstemp(char *template)
242 start = strlen(template) - 1;
243 while(template[start] == 'X') {
244 template[start] = '0' + val % 10;
251 fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600);
252 if(fd >= 0 || errno != EEXIST)
259 if(template[i] == '9' + 1)
261 if(template[i] <= 'z')
270 #if defined(KRB5) && !defined(HEIMDAL)
271 /* Needed to work around problems with replay caches */
272 #include "mit-internals.h"
274 /* This is our replacement krb5_rc_store function */
275 static krb5_error_code KRB5_LIB_FUNCTION
276 mod_auth_kerb_rc_store(krb5_context context, krb5_rcache rcache,
277 krb5_donot_replay_internal *donot_replay)
282 /* And this is the operations vector for our replay cache */
283 const krb5_rc_ops_internal mod_auth_kerb_rc_ops = {
290 mod_auth_kerb_rc_store,
292 krb5_rc_dfl_get_span,
293 krb5_rc_dfl_get_name,
299 /***************************************************************************
300 Auth Configuration Initialization
301 ***************************************************************************/
302 static void *kerb_dir_create_config(MK_POOL *p, char *d)
304 kerb_auth_config *rec;
306 rec = (kerb_auth_config *) ap_pcalloc(p, sizeof(kerb_auth_config));
307 ((kerb_auth_config *)rec)->krb_verify_kdc = 1;
308 ((kerb_auth_config *)rec)->krb_service_name = NULL;
309 ((kerb_auth_config *)rec)->krb_authoritative = 1;
310 ((kerb_auth_config *)rec)->krb_delegate_basic = 0;
311 ((kerb_auth_config *)rec)->krb_ssl_preauthentication = 0;
313 ((kerb_auth_config *)rec)->krb_method_k5pass = 1;
314 ((kerb_auth_config *)rec)->krb_method_gssapi = 1;
317 ((kerb_auth_config *)rec)->krb_method_k4pass = 1;
323 krb5_save_realms(cmd_parms *cmd, void *vsec, const char *arg)
325 kerb_auth_config *sec = (kerb_auth_config *) vsec;
326 sec->krb_auth_realms= ap_pstrdup(cmd->pool, arg);
331 log_rerror(const char *file, int line, int level, int status,
332 const request_rec *r, const char *fmt, ...)
338 vsnprintf(errstr, sizeof(errstr), fmt, ap);
342 #ifdef STANDARD20_MODULE_STUFF
343 ap_log_rerror(file, line, level | APLOG_NOERRNO, status, r, "%s", errstr);
345 ap_log_rerror(file, line, level | APLOG_NOERRNO, r, "%s", errstr);
350 /***************************************************************************
351 Username/Password Validation for Krb4
352 ***************************************************************************/
354 verify_krb4_user(request_rec *r, char *name, char *instance, char *realm,
355 char *password, char *linstance, char *srvtab, int krb_verify_kdc)
361 const char *hostname;
364 char lrealm[REALM_SZ];
366 ret = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm,
367 DEFAULT_TKT_LIFE, password);
369 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
370 "Cannot get krb4 ticket: krb_get_pw_in_tkt() failed: %s",
371 krb_get_err_text(ret));
378 hostname = ap_get_server_name(r);
380 hp = gethostbyname(hostname);
383 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
384 "Cannot verify krb4 ticket: gethostbyname() failed: %s",
388 memcpy(&addr, hp->h_addr, sizeof(addr));
390 phost = krb_get_phost((char *)hostname);
392 krb_get_lrealm(lrealm, 1);
394 ret = krb_mk_req(&ticket, linstance, phost, lrealm, 0);
396 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
397 "Cannot verify krb4 ticket: krb_mk_req() failed: %s",
398 krb_get_err_text(ret));
403 ret = krb_rd_req(&ticket, linstance, phost, addr, &authdata, srvtab);
405 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
406 "Cannot verify krb4 ticket: krb_rd_req() failed: %s",
407 krb_get_err_text(ret));
415 krb4_cache_cleanup(void *data)
417 char *tkt_file = (char *) data;
419 krb_set_tkt_string(tkt_file);
425 authenticate_user_krb4pwd(request_rec *r,
426 kerb_auth_config *conf,
427 const char *auth_line)
431 const char *sent_name;
434 char *tkt_file_p = NULL;
439 char lrealm[REALM_SZ];
440 int all_principals_unkown;
442 sent_pw = ap_pbase64decode(r->pool, auth_line);
443 sent_name = ap_getword (r->pool, &sent_pw, ':');
445 /* do not allow user to override realm setting of server */
446 if (ap_strchr_c(sent_name, '@')) {
447 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
448 "specifying realm in user name is prohibited");
449 return HTTP_UNAUTHORIZED;
452 sent_instance = strchr(sent_name, '.');
454 *sent_instance++ = '\0';
456 snprintf(tkt_file, sizeof(tkt_file), "/tmp/apache_tkt_XXXXXX");
457 fd = mkstemp(tkt_file);
459 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
460 "Cannot create krb4 ccache: mkstemp() failed: %s",
462 return HTTP_INTERNAL_SERVER_ERROR;
465 tkt_file_p = ap_pstrdup(r->pool, tkt_file);
466 ap_register_cleanup(r->pool, tkt_file_p,
467 krb4_cache_cleanup, ap_null_cleanup);
469 krb_set_tkt_string(tkt_file);
471 all_principals_unkown = 1;
472 realms = conf->krb_auth_realms;
474 memset(lrealm, 0, sizeof(lrealm));
477 realm = ap_getword_white(r->pool, &realms);
480 ret = krb_get_lrealm(lrealm, 1);
486 /* XXX conf->krb_service_name */
487 ret = verify_krb4_user(r, (char *)sent_name,
488 (sent_instance) ? sent_instance : "",
489 (char *)realm, (char *)sent_pw,
490 conf->krb_service_name,
491 conf->krb_4_srvtab, conf->krb_verify_kdc);
492 if (!conf->krb_authoritative && ret) {
493 /* if we're not authoritative, we allow authentication to pass on
494 * to another modules if (and only if) the user is not known to us */
495 if (all_principals_unkown && ret != KDC_PR_UNKNOWN)
496 all_principals_unkown = 0;
501 } while (realms && *realms);
504 /* XXX log only in the verify_krb4_user() call */
505 log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Verifying krb4 password failed");
506 ret = (!conf->krb_authoritative && all_principals_unkown == 1 && ret == KDC_PR_UNKNOWN) ?
507 DECLINED : HTTP_UNAUTHORIZED;
511 user = ap_pstrdup(r->pool, sent_name);
513 user = ap_pstrcat(r->pool, user, ".", sent_instance, NULL);
514 user = ap_pstrcat(r->pool, user, "@", realm, NULL);
517 MK_AUTH_TYPE = "Basic";
518 ap_table_setn(r->subprocess_env, "KRBTKFILE", tkt_file_p);
520 if (!conf->krb_save_credentials)
521 krb4_cache_cleanup(tkt_file);
525 krb4_cache_cleanup(tkt_file);
534 /***************************************************************************
535 Username/Password Validation for Krb5
536 ***************************************************************************/
538 /* MIT kerberos uses replay cache checks even during credential verification
539 * (i.e. in krb5_verify_init_creds()), which is obviosuly useless. In order to
540 * avoid problems with multiple apache processes accessing the same rcache file
541 * we had to use this call instead, which is only a bit modified version of
542 * krb5_verify_init_creds() */
543 static krb5_error_code
544 verify_krb5_init_creds(request_rec *r, krb5_context context, krb5_creds *creds,
545 krb5_principal ap_req_server, krb5_keytab ap_req_keytab)
549 krb5_ccache local_ccache = NULL;
550 krb5_creds *new_creds = NULL;
551 krb5_auth_context auth_context = NULL;
552 krb5_keytab keytab = NULL;
555 memset(&req, 0, sizeof(req));
557 if (ap_req_keytab == NULL) {
558 ret = krb5_kt_default (context, &keytab);
562 keytab = ap_req_keytab;
564 ret = krb5_cc_resolve(context, "MEMORY:", &local_ccache);
566 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
567 "krb5_cc_resolve() failed when verifying KDC");
571 ret = krb5_cc_initialize(context, local_ccache, creds->client);
573 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
574 "krb5_cc_initialize() failed when verifying KDC");
578 ret = krb5_cc_store_cred (context, local_ccache, creds);
580 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
581 "krb5_cc_initialize() failed when verifying KDC");
585 ret = krb5_unparse_name(context, ap_req_server, &server_name);
587 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
588 "krb5_unparse_name() failed when verifying KDC");
591 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
592 "Trying to verify authenticity of KDC using principal %s", server_name);
595 if (!krb5_principal_compare (context, ap_req_server, creds->server)) {
596 krb5_creds match_cred;
598 memset (&match_cred, 0, sizeof(match_cred));
600 match_cred.client = creds->client;
601 match_cred.server = ap_req_server;
603 ret = krb5_get_credentials (context, 0, local_ccache,
604 &match_cred, &new_creds);
606 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
607 "krb5_get_credentials() failed when verifying KDC");
613 ret = krb5_mk_req_extended (context, &auth_context, 0, NULL, creds, &req);
615 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
616 "krb5_mk_req_extended() failed when verifying KDC");
620 krb5_auth_con_free (context, auth_context);
622 ret = krb5_auth_con_init(context, &auth_context);
624 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
625 "krb5_auth_con_init() failed when verifying KDC");
628 /* use KRB5_AUTH_CONTEXT_DO_SEQUENCE to skip replay cache checks */
629 krb5_auth_con_setflags(context, auth_context, KRB5_AUTH_CONTEXT_DO_SEQUENCE);
631 ret = krb5_rd_req (context, &auth_context, &req, ap_req_server,
634 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
635 "krb5_rd_req() failed when verifying KDC");
641 /* XXX Do I ever want to support Heimdal 0.4 ??? */
642 krb5_data_free(&req);
644 krb5_free_data_contents(context, &req);
647 krb5_auth_con_free (context, auth_context);
649 krb5_free_creds (context, new_creds);
650 if (ap_req_keytab == NULL && keytab)
651 krb5_kt_close (context, keytab);
653 krb5_cc_destroy (context, local_ccache);
658 /* Inspired by krb5_verify_user from Heimdal */
659 static krb5_error_code
660 verify_krb5_user(request_rec *r, krb5_context context, krb5_principal principal,
661 const char *password, krb5_principal server,
662 krb5_keytab keytab, int krb_verify_kdc, krb5_ccache *ccache)
666 krb5_ccache ret_ccache = NULL;
669 /* XXX error messages shouldn't be logged here (and in the while() loop in
670 * authenticate_user_krb5pwd() as weell), in order to avoid confusing log
671 * entries when using multiple realms */
673 memset(&creds, 0, sizeof(creds));
675 ret = krb5_unparse_name(context, principal, &name);
677 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
678 "Trying to get TGT for user %s", name);
682 ret = krb5_get_init_creds_password(context, &creds, principal,
683 (char *)password, NULL,
684 NULL, 0, NULL, NULL);
686 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
687 "krb5_get_init_creds_password() failed: %s",
688 krb5_get_err_text(context, ret));
696 krb5_get_default_realm(context, &realm);
697 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
698 "trying to verify password using key for %s/%s@%s",
699 service, ap_get_server_name(r), realm);
703 if (krb_verify_kdc &&
704 (ret = verify_krb5_init_creds(r, context, &creds, server, keytab))) {
705 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
706 "failed to verify krb5 credentials: %s",
707 krb5_get_err_text(context, ret));
711 ret = krb5_cc_resolve(context, "MEMORY:", &ret_ccache);
713 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
714 "generating new memory ccache failed: %s",
715 krb5_get_err_text(context, ret));
719 ret = krb5_cc_initialize(context, ret_ccache, principal);
721 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
722 "krb5_cc_initialize() failed: %s",
723 krb5_get_err_text(context, ret));
727 ret = krb5_cc_store_cred(context, ret_ccache, &creds);
729 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
730 "krb5_cc_store_cred() failed: %s",
731 krb5_get_err_text(context, ret));
734 *ccache = ret_ccache;
738 krb5_free_cred_contents(context, &creds);
740 krb5_cc_destroy(context, ret_ccache);
746 krb5_cache_cleanup(void *data)
748 krb5_context context;
750 krb5_error_code problem;
751 char *cache_name = (char *) data;
753 problem = krb5_init_context(&context);
755 /* ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "krb5_init_context() failed"); */
756 return HTTP_INTERNAL_SERVER_ERROR;
759 problem = krb5_cc_resolve(context, cache_name, &cache);
761 /* log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
762 "krb5_cc_resolve() failed (%s: %s)",
763 cache_name, krb5_get_err_text(context, problem)); */
764 return HTTP_INTERNAL_SERVER_ERROR;
767 krb5_cc_destroy(context, cache);
768 krb5_free_context(context);
773 create_krb5_ccache(krb5_context kcontext,
775 kerb_auth_config *conf,
776 krb5_principal princ,
781 krb5_error_code problem;
783 krb5_ccache tmp_ccache = NULL;
785 ccname = ap_psprintf(r->pool, "FILE:%s/krb5cc_apache_XXXXXX", P_tmpdir);
786 fd = mkstemp(ccname + strlen("FILE:"));
788 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
789 "mkstemp() failed: %s", strerror(errno));
790 ret = HTTP_INTERNAL_SERVER_ERROR;
795 problem = krb5_cc_resolve(kcontext, ccname, &tmp_ccache);
797 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
798 "krb5_cc_resolve() failed: %s",
799 krb5_get_err_text(kcontext, problem));
800 ret = HTTP_INTERNAL_SERVER_ERROR;
805 problem = krb5_cc_initialize(kcontext, tmp_ccache, princ);
807 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
808 "Cannot initialize krb5 ccache %s: krb5_cc_initialize() failed: %s",
809 ccname, krb5_get_err_text(kcontext, problem));
810 ret = HTTP_INTERNAL_SERVER_ERROR;
814 ap_table_setn(r->subprocess_env, "KRB5CCNAME", ccname);
815 ap_register_cleanup(r->pool, ccname,
816 krb5_cache_cleanup, ap_null_cleanup);
818 *ccache = tmp_ccache;
825 krb5_cc_destroy(kcontext, tmp_ccache);
831 store_krb5_creds(krb5_context kcontext,
833 kerb_auth_config *conf,
834 krb5_ccache delegated_cred)
837 krb5_error_code problem;
838 krb5_principal princ;
842 problem = krb5_cc_get_principal(kcontext, delegated_cred, &princ);
844 snprintf(errstr, sizeof(errstr), "krb5_cc_get_principal() failed: %s",
845 krb5_get_err_text(kcontext, problem));
846 return HTTP_INTERNAL_SERVER_ERROR;
849 ret = create_krb5_ccache(kcontext, r, conf, princ, &ccache);
851 krb5_free_principal(kcontext, princ);
856 problem = krb5_cc_copy_cache(kcontext, delegated_cred, ccache);
858 problem = krb5_cc_copy_creds(kcontext, delegated_cred, ccache);
860 krb5_free_principal(kcontext, princ);
862 snprintf(errstr, sizeof(errstr), "Failed to store credentials: %s",
863 krb5_get_err_text(kcontext, problem));
864 krb5_cc_destroy(kcontext, ccache);
865 return HTTP_INTERNAL_SERVER_ERROR;
868 krb5_cc_close(kcontext, ccache);
874 authenticate_user_krb5pwd(request_rec *r,
875 kerb_auth_config *conf,
876 const char *auth_line)
878 const char *sent_pw = NULL;
879 const char *sent_name = NULL;
880 const char *realms = NULL;
881 const char *realm = NULL;
882 krb5_context kcontext = NULL;
883 krb5_error_code code;
884 krb5_principal client = NULL;
885 krb5_principal server = NULL;
886 krb5_ccache ccache = NULL;
887 krb5_keytab keytab = NULL;
890 int all_principals_unkown;
893 code = krb5_init_context(&kcontext);
895 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
896 "Cannot initialize Kerberos5 context (%d)", code);
897 return HTTP_INTERNAL_SERVER_ERROR;
900 sent_pw = ap_pbase64decode(r->pool, auth_line);
901 sent_name = ap_getword (r->pool, &sent_pw, ':');
903 if (sent_pw == NULL || *sent_pw == '\0') {
904 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
905 "empty passwords are not accepted");
906 ret = HTTP_UNAUTHORIZED;
910 if (conf->krb_5_keytab)
911 krb5_kt_resolve(kcontext, conf->krb_5_keytab, &keytab);
913 if (conf->krb_service_name && strchr(conf->krb_service_name, '/') != NULL)
914 ret = krb5_parse_name (kcontext, conf->krb_service_name, &server);
916 ret = krb5_sname_to_principal(kcontext, ap_get_server_name(r),
917 (conf->krb_service_name) ? conf->krb_service_name : SERVICE_NAME,
918 KRB5_NT_SRV_HST, &server);
921 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
922 "Error parsing server name (%s): %s",
923 (conf->krb_service_name) ? conf->krb_service_name : SERVICE_NAME,
924 krb5_get_err_text(kcontext, ret));
925 ret = HTTP_UNAUTHORIZED;
929 code = krb5_unparse_name(kcontext, server, &name);
931 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
932 "krb5_unparse_name() failed: %s",
933 krb5_get_err_text(kcontext, code));
934 ret = HTTP_UNAUTHORIZED;
937 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Using %s as server principal for password verification", name);
941 p = strchr(sent_name, '@');
944 if (conf->krb_auth_realms && !ap_find_token(r->pool, conf->krb_auth_realms, p)) {
945 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
946 "Specified realm `%s' not allowed by configuration", p);
947 ret = HTTP_UNAUTHORIZED;
952 realms = (p) ? p : conf->krb_auth_realms;
953 all_principals_unkown = 1;
955 name = (char *) sent_name;
956 if (realms && (realm = ap_getword_white(r->pool, &realms)))
957 name = ap_psprintf(r->pool, "%s@%s", sent_name, realm);
960 krb5_free_principal(kcontext, client);
964 code = krb5_parse_name(kcontext, name, &client);
966 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
967 "krb5_parse_name() failed: %s",
968 krb5_get_err_text(kcontext, code));
972 code = verify_krb5_user(r, kcontext, client, sent_pw,
973 server, keytab, conf->krb_verify_kdc, &ccache);
974 if (!conf->krb_authoritative && code) {
975 /* if we're not authoritative, we allow authentication to pass on
976 * to another modules if (and only if) the user is not known to us */
977 if (all_principals_unkown && code != KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN)
978 all_principals_unkown = 0;
984 /* ap_getword_white() used above shifts the parameter, so it's not
985 needed to touch the realms variable */
986 } while (realms && *realms);
988 memset((char *)sent_pw, 0, strlen(sent_pw));
991 if (!conf->krb_authoritative && all_principals_unkown == 1 && code == KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN)
994 ret = HTTP_UNAUTHORIZED;
999 code = krb5_unparse_name(kcontext, client, &name);
1001 log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "krb5_unparse_name() failed: %s",
1002 krb5_get_err_text(kcontext, code));
1003 ret = HTTP_UNAUTHORIZED;
1006 MK_USER = ap_pstrdup (r->pool, name);
1007 MK_AUTH_TYPE = "Basic";
1010 if (conf->krb_save_credentials)
1011 store_krb5_creds(kcontext, r, conf, ccache);
1016 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
1017 "kerb_authenticate_user_krb5pwd ret=%d user=%s authtype=%s",
1018 ret, (MK_USER)?MK_USER:"(NULL)", (MK_AUTH_TYPE)?MK_AUTH_TYPE:"(NULL)");
1020 krb5_free_principal(kcontext, client);
1022 krb5_free_principal(kcontext, server);
1024 krb5_cc_destroy(kcontext, ccache);
1026 krb5_kt_close(kcontext, keytab);
1027 krb5_free_context(kcontext);
1032 /*********************************************************************
1033 * GSSAPI Authentication
1034 ********************************************************************/
1037 get_gss_error(MK_POOL *p, OM_uint32 err_maj, OM_uint32 err_min, char *prefix)
1039 OM_uint32 maj_stat, min_stat;
1040 OM_uint32 msg_ctx = 0;
1041 gss_buffer_desc status_string;
1044 err_msg = ap_pstrdup(p, prefix);
1046 maj_stat = gss_display_status (&min_stat,
1052 if (GSS_ERROR(maj_stat))
1054 err_msg = ap_pstrcat(p, err_msg, ": ", (char*) status_string.value, NULL);
1055 gss_release_buffer(&min_stat, &status_string);
1057 maj_stat = gss_display_status (&min_stat,
1063 if (!GSS_ERROR(maj_stat)) {
1064 err_msg = ap_pstrcat(p, err_msg,
1065 " (", (char*) status_string.value, ")", NULL);
1066 gss_release_buffer(&min_stat, &status_string);
1068 } while (!GSS_ERROR(maj_stat) && msg_ctx != 0);
1074 store_gss_creds(request_rec *r, kerb_auth_config *conf, char *princ_name,
1075 gss_cred_id_t delegated_cred)
1077 OM_uint32 maj_stat, min_stat;
1078 krb5_principal princ = NULL;
1079 krb5_ccache ccache = NULL;
1080 krb5_error_code problem;
1081 krb5_context context;
1082 int ret = HTTP_INTERNAL_SERVER_ERROR;
1084 problem = krb5_init_context(&context);
1086 log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Cannot initialize krb5 context");
1087 return HTTP_INTERNAL_SERVER_ERROR;
1090 problem = krb5_parse_name(context, princ_name, &princ);
1092 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1093 "Cannot parse delegated username (%s)", krb5_get_err_text(context, problem));
1097 problem = create_krb5_ccache(context, r, conf, princ, &ccache);
1099 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1100 "Cannot create krb5 ccache (%s)", krb5_get_err_text(context, problem));
1104 maj_stat = gss_krb5_copy_ccache(&min_stat, delegated_cred, ccache);
1105 if (GSS_ERROR(maj_stat)) {
1106 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1107 "Cannot store delegated credential (%s)",
1108 get_gss_error(r->pool, maj_stat, min_stat, "gss_krb5_copy_ccache"));
1112 krb5_cc_close(context, ccache);
1118 krb5_free_principal(context, princ);
1120 krb5_cc_destroy(context, ccache);
1121 krb5_free_context(context);
1126 get_gss_creds(request_rec *r,
1127 kerb_auth_config *conf,
1128 gss_cred_id_t *server_creds)
1130 gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
1131 OM_uint32 major_status, minor_status, minor_status2;
1132 gss_name_t server_name = GSS_C_NO_NAME;
1134 int have_server_princ;
1136 have_server_princ = conf->krb_service_name && strchr(conf->krb_service_name, '/') != NULL;
1137 if (have_server_princ)
1138 strncpy(buf, conf->krb_service_name, sizeof(buf));
1140 snprintf(buf, sizeof(buf), "%s@%s",
1141 (conf->krb_service_name) ? conf->krb_service_name : SERVICE_NAME,
1142 ap_get_server_name(r));
1145 token.length = strlen(buf) + 1;
1147 major_status = gss_import_name(&minor_status, &token,
1148 (have_server_princ) ? GSS_KRB5_NT_PRINCIPAL_NAME : GSS_C_NT_HOSTBASED_SERVICE,
1150 memset(&token, 0, sizeof(token));
1151 if (GSS_ERROR(major_status)) {
1152 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1153 "%s", get_gss_error(r->pool, major_status, minor_status,
1154 "gss_import_name() failed"));
1155 return HTTP_INTERNAL_SERVER_ERROR;
1158 major_status = gss_display_name(&minor_status, server_name, &token, NULL);
1159 if (GSS_ERROR(major_status)) {
1160 /* Perhaps we could just ignore this error but it's safer to give up now,
1162 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1163 "%s", get_gss_error(r->pool, major_status, minor_status,
1164 "gss_display_name() failed"));
1165 return HTTP_INTERNAL_SERVER_ERROR;
1168 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Acquiring creds for %s",
1170 gss_release_buffer(&minor_status, &token);
1172 major_status = gss_acquire_cred(&minor_status, server_name, GSS_C_INDEFINITE,
1173 GSS_C_NO_OID_SET, GSS_C_ACCEPT,
1174 server_creds, NULL, NULL);
1175 gss_release_name(&minor_status2, &server_name);
1176 if (GSS_ERROR(major_status)) {
1177 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1178 "%s", get_gss_error(r->pool, major_status, minor_status,
1179 "gss_acquire_cred() failed"));
1180 return HTTP_INTERNAL_SERVER_ERROR;
1185 * With MIT Kerberos 5 1.3.x the gss_cred_id_t is the same as
1186 * krb5_gss_cred_id_t and krb5_gss_cred_id_rec contains a pointer to
1188 * This allows us to override the replay cache function vector with
1190 * Note that this is a dirty hack to get things working and there may
1191 * well be unknown side-effects.
1194 krb5_gss_cred_id_t gss_creds = (krb5_gss_cred_id_t) *server_creds;
1196 if (gss_creds && gss_creds->rcache && gss_creds->rcache->ops &&
1197 gss_creds->rcache->ops->type &&
1198 memcmp(gss_creds->rcache->ops->type, "dfl", 3) == 0)
1199 /* Override the rcache operations */
1200 gss_creds->rcache->ops = &mod_auth_kerb_rc_ops;
1208 cmp_gss_type(gss_buffer_t token, gss_OID oid)
1213 if (token->length == 0)
1214 return GSS_S_DEFECTIVE_TOKEN;
1218 return GSS_S_DEFECTIVE_TOKEN;
1221 if ((len & 0x7f) > 4)
1222 return GSS_S_DEFECTIVE_TOKEN;
1226 return GSS_S_DEFECTIVE_TOKEN;
1228 if (((OM_uint32) *p++) != oid->length)
1229 return GSS_S_DEFECTIVE_TOKEN;
1231 return memcmp(p, oid->elements, oid->length);
1235 authenticate_user_gss(request_rec *r, kerb_auth_config *conf,
1236 const char *auth_line, char **negotiate_ret_value)
1238 OM_uint32 major_status, minor_status, minor_status2;
1239 gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
1240 gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
1241 const char *auth_param = NULL;
1243 gss_name_t client_name = GSS_C_NO_NAME;
1244 gss_cred_id_t delegated_cred = GSS_C_NO_CREDENTIAL;
1245 OM_uint32 (KRB5_LIB_FUNCTION *accept_sec_token)
1246 (OM_uint32 *, gss_ctx_id_t *, const gss_cred_id_t,
1247 const gss_buffer_t, const gss_channel_bindings_t,
1248 gss_name_t *, gss_OID *, gss_buffer_t, OM_uint32 *,
1249 OM_uint32 *, gss_cred_id_t *);
1250 gss_OID_desc spnego_oid;
1251 gss_ctx_id_t context = GSS_C_NO_CONTEXT;
1252 gss_cred_id_t server_creds = GSS_C_NO_CREDENTIAL;
1254 *negotiate_ret_value = "\0";
1256 spnego_oid.length = 6;
1257 spnego_oid.elements = (void *)"\x2b\x06\x01\x05\x05\x02";
1259 if (conf->krb_5_keytab) {
1261 /* we don't use the ap_* calls here, since the string passed to putenv()
1262 * will become part of the enviroment and shouldn't be free()ed by apache
1264 ktname = malloc(strlen("KRB5_KTNAME=") + strlen(conf->krb_5_keytab) + 1);
1265 if (ktname == NULL) {
1266 log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "malloc() failed: not enough memory");
1267 ret = HTTP_INTERNAL_SERVER_ERROR;
1270 sprintf(ktname, "KRB5_KTNAME=%s", conf->krb_5_keytab);
1273 /* Seems to be also supported by latest MIT */
1274 gsskrb5_register_acceptor_identity(conf->krb_5_keytab);
1278 ret = get_gss_creds(r, conf, &server_creds);
1282 /* ap_getword() shifts parameter */
1283 auth_param = ap_getword_white(r->pool, &auth_line);
1284 if (auth_param == NULL) {
1285 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1286 "No Authorization parameter in request from client");
1287 ret = HTTP_UNAUTHORIZED;
1291 input_token.length = ap_base64decode_len(auth_param) + 1;
1292 input_token.value = ap_pcalloc(r->connection->pool, input_token.length);
1293 if (input_token.value == NULL) {
1294 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1295 "ap_pcalloc() failed (not enough memory)");
1296 ret = HTTP_INTERNAL_SERVER_ERROR;
1299 input_token.length = ap_base64decode(input_token.value, auth_param);
1301 #ifdef GSSAPI_SUPPORTS_SPNEGO
1302 accept_sec_token = gss_accept_sec_context;
1304 accept_sec_token = (cmp_gss_type(&input_token, &spnego_oid) == 0) ?
1305 gss_accept_sec_context_spnego : gss_accept_sec_context;
1308 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Verifying client data using %s",
1309 (accept_sec_token == gss_accept_sec_context)
1311 : "SPNEGO GSS-API");
1313 major_status = accept_sec_token(&minor_status,
1317 GSS_C_NO_CHANNEL_BINDINGS,
1324 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
1325 "Verification returned code %d", major_status);
1326 if (output_token.length) {
1330 len = ap_base64encode_len(output_token.length) + 1;
1331 token = ap_pcalloc(r->connection->pool, len + 1);
1332 if (token == NULL) {
1333 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1334 "ap_pcalloc() failed (not enough memory)");
1335 ret = HTTP_INTERNAL_SERVER_ERROR;
1336 gss_release_buffer(&minor_status2, &output_token);
1339 ap_base64encode(token, output_token.value, output_token.length);
1341 *negotiate_ret_value = token;
1342 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
1343 "GSS-API token of length %d bytes will be sent back",
1344 output_token.length);
1345 gss_release_buffer(&minor_status2, &output_token);
1346 set_kerb_auth_headers(r, conf, 0, 0, *negotiate_ret_value);
1349 if (GSS_ERROR(major_status)) {
1350 if (input_token.length > 7 && memcmp(input_token.value, "NTLMSSP", 7) == 0)
1351 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
1352 "Warning: received token seems to be NTLM, which isn't supported by the Kerberos module. Check your IE configuration.");
1354 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1355 "%s", get_gss_error(r->pool, major_status, minor_status,
1356 "gss_accept_sec_context() failed"));
1357 /* Don't offer the Negotiate method again if call to GSS layer failed */
1358 *negotiate_ret_value = NULL;
1359 ret = HTTP_UNAUTHORIZED;
1364 /* This is a _Kerberos_ module so multiple authentication rounds aren't
1365 * supported. If we wanted a generic GSS authentication we would have to do
1366 * some magic with exporting context etc. */
1367 if (major_status & GSS_S_CONTINUE_NEEDED) {
1368 ret = HTTP_UNAUTHORIZED;
1373 major_status = gss_display_name(&minor_status, client_name, &output_token, NULL);
1374 gss_release_name(&minor_status, &client_name);
1375 if (GSS_ERROR(major_status)) {
1376 log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1377 "%s", get_gss_error(r->pool, major_status, minor_status,
1378 "gss_export_name() failed"));
1379 ret = HTTP_INTERNAL_SERVER_ERROR;
1383 MK_AUTH_TYPE = MECH_NEGOTIATE;
1384 MK_USER = ap_pstrdup(r->pool, output_token.value);
1386 if (conf->krb_save_credentials && delegated_cred != GSS_C_NO_CREDENTIAL)
1387 store_gss_creds(r, conf, (char *)output_token.value, delegated_cred);
1389 gss_release_buffer(&minor_status, &output_token);
1395 gss_release_cred(&minor_status, &delegated_cred);
1397 if (output_token.length)
1398 gss_release_buffer(&minor_status, &output_token);
1400 if (client_name != GSS_C_NO_NAME)
1401 gss_release_name(&minor_status, &client_name);
1403 if (server_creds != GSS_C_NO_CREDENTIAL)
1404 gss_release_cred(&minor_status, &server_creds);
1406 if (context != GSS_C_NO_CONTEXT)
1407 gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
1414 already_succeeded(request_rec *r)
1416 if (ap_is_initial_req(r) || MK_AUTH_TYPE == NULL)
1418 if (strcmp(MK_AUTH_TYPE, MECH_NEGOTIATE) ||
1419 (strcmp(MK_AUTH_TYPE, "Basic") && strchr(MK_USER, '@')))
1425 set_kerb_auth_headers(request_rec *r, const kerb_auth_config *conf,
1426 int use_krb4, int use_krb5pwd, char *negotiate_ret_value)
1428 const char *auth_name = NULL;
1430 char *negoauth_param;
1431 const char *header_name =
1432 (r->proxyreq == PROXYREQ_PROXY) ? "Proxy-Authenticate" : "WWW-Authenticate";
1434 /* get the user realm specified in .htaccess */
1435 auth_name = ap_auth_name(r);
1437 /* XXX should the WWW-Authenticate header be cleared first?
1438 * apache in the proxy mode should retain client's authN headers? */
1440 if (negotiate_ret_value != NULL && conf->krb_method_gssapi) {
1441 negoauth_param = (*negotiate_ret_value == '\0') ? MECH_NEGOTIATE :
1442 ap_pstrcat(r->pool, MECH_NEGOTIATE " ", negotiate_ret_value, NULL);
1443 ap_table_add(r->err_headers_out, header_name, negoauth_param);
1445 if ((use_krb5pwd && conf->krb_method_k5pass) || conf->krb_delegate_basic) {
1446 ap_table_add(r->err_headers_out, header_name,
1447 ap_pstrcat(r->pool, "Basic realm=\"", auth_name, "\"", NULL));
1454 ((use_krb4 && conf->krb_method_k4pass) || conf->krb_delegate_basic))
1455 ap_table_add(r->err_headers_out, header_name,
1456 ap_pstrcat(r->pool, "Basic realm=\"", auth_name, "\"", NULL));
1461 kerb_authenticate_user(request_rec *r)
1463 kerb_auth_config *conf =
1464 (kerb_auth_config *) ap_get_module_config(r->per_dir_config,
1466 const char *auth_type = NULL;
1467 const char *auth_line = NULL;
1468 const char *type = NULL;
1469 int use_krb5 = 0, use_krb4 = 0;
1471 static int last_return = HTTP_UNAUTHORIZED;
1472 char *negotiate_ret_value = NULL;
1474 /* get the type specified in .htaccess */
1475 type = ap_auth_type(r);
1477 log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
1478 "kerb_authenticate_user entered with user %s and auth_type %s",
1479 (MK_USER)?MK_USER:"(NULL)",type?type:"(NULL)");
1481 if (type && strcasecmp(type, "Kerberos") == 0)
1482 use_krb5 = use_krb4 = 1;
1483 else if(type && strcasecmp(type, "KerberosV5") == 0)
1485 else if(type && strcasecmp(type, "KerberosV4") == 0)
1490 if (conf->krb_ssl_preauthentication) {
1491 const char *ssl_client_verify = ssl_var_lookup(r->pool, r->server,
1492 r->connection, r, "SSL_CLIENT_VERIFY");
1494 if (ssl_client_verify && strcmp(ssl_client_verify, "SUCCESS") == 0)
1498 /* get what the user sent us in the HTTP header */
1499 auth_line = MK_TABLE_GET(r->headers_in, (r->proxyreq == PROXYREQ_PROXY)
1500 ? "Proxy-Authorization"
1503 set_kerb_auth_headers(r, conf, use_krb4, use_krb5,
1504 (use_krb5) ? "\0" : NULL);
1505 return HTTP_UNAUTHORIZED;
1507 auth_type = ap_getword_white(r->pool, &auth_line);
1509 /* If we are delegating Basic to other modules, DECLINE the request */
1510 if (conf->krb_delegate_basic &&
1512 !conf->krb_method_k5pass &&
1515 !conf->krb_method_k4pass &&
1517 (strcasecmp(auth_type, "Basic") == 0))
1520 if (already_succeeded(r))
1523 ret = HTTP_UNAUTHORIZED;
1526 if (use_krb5 && conf->krb_method_gssapi &&
1527 strcasecmp(auth_type, MECH_NEGOTIATE) == 0) {
1528 ret = authenticate_user_gss(r, conf, auth_line, &negotiate_ret_value);
1529 } else if (use_krb5 && conf->krb_method_k5pass &&
1530 strcasecmp(auth_type, "Basic") == 0) {
1531 ret = authenticate_user_krb5pwd(r, conf, auth_line);
1536 if (ret == HTTP_UNAUTHORIZED && use_krb4 && conf->krb_method_k4pass &&
1537 strcasecmp(auth_type, "Basic") == 0)
1538 ret = authenticate_user_krb4pwd(r, conf, auth_line);
1541 if (ret == HTTP_UNAUTHORIZED)
1542 set_kerb_auth_headers(r, conf, use_krb4, use_krb5, negotiate_ret_value);
1544 /* XXX log_debug: if ret==OK, log(user XY authenticated) */
1551 /***************************************************************************
1552 Module Setup/Configuration
1553 ***************************************************************************/
1554 #ifndef STANDARD20_MODULE_STUFF
1555 module MODULE_VAR_EXPORT auth_kerb_module = {
1556 STANDARD_MODULE_STUFF,
1557 NULL, /* module initializer */
1558 kerb_dir_create_config, /* per-directory config creator */
1559 NULL, /* per-directory config merger */
1560 NULL, /* per-server config creator */
1561 NULL, /* per-server config merger */
1562 kerb_auth_cmds, /* command table */
1563 NULL, /* [ 9] content handlers */
1564 NULL, /* [ 2] URI-to-filename translation */
1565 kerb_authenticate_user, /* [ 5] check/validate user_id */
1566 NULL, /* [ 6] check user_id is valid *here* */
1567 NULL, /* [ 4] check access by host address */
1568 NULL, /* [ 7] MIME type checker/setter */
1569 NULL, /* [ 8] fixups */
1570 NULL, /* [10] logger */
1571 NULL, /* [ 3] header parser */
1572 NULL, /* process initialization */
1573 NULL, /* process exit/cleanup */
1574 NULL /* [ 1] post read_request handling */
1576 ,NULL, /* EAPI: add_module */
1577 NULL, /* EAPI: remove_module */
1578 NULL, /* EAPI: rewrite_command */
1579 NULL /* EAPI: new_connection */
1584 kerb_init_handler(apr_pool_t *p, apr_pool_t *plog,
1585 apr_pool_t *ptemp, server_rec *s)
1587 ap_add_version_component(p, "mod_auth_kerb/" MODAUTHKERB_VERSION);
1592 kerb_register_hooks(apr_pool_t *p)
1594 ap_hook_post_config(kerb_init_handler, NULL, NULL, APR_HOOK_MIDDLE);
1595 ap_hook_check_user_id(kerb_authenticate_user, NULL, NULL, APR_HOOK_MIDDLE);
1598 module AP_MODULE_DECLARE_DATA auth_kerb_module =
1600 STANDARD20_MODULE_STUFF,
1601 kerb_dir_create_config, /* create per-dir conf structures */
1602 NULL, /* merge per-dir conf structures */
1603 NULL, /* create per-server conf structures */
1604 NULL, /* merge per-server conf structures */
1605 kerb_auth_cmds, /* table of configuration directives */
1606 kerb_register_hooks /* register hooks */