#ifdef KRB5
#include <krb5.h>
-#include <gssapi.h>
#endif /* KRB5 */
+#ifdef GSSAPI
+#include <gssapi.h>
+#endif /* GSSAPI */
+
#ifdef KRB4
#include <krb.h>
#endif /* KRB4 */
Auth Configuration Structure
***************************************************************************/
typedef struct {
- char *krb_auth_type;
#ifdef KRB4
char *krb_4_srvtab;
#endif /* KRB4 */
#ifdef KRB5
char *krb_5_keytab;
#endif /* KRB5 */
+ int krb_auth_enable;
+ char *krb_auth_realms;
int krb_authoritative;
- char *krb_default_realm;
int krb_fail_status;
char *krb_force_instance;
#ifdef KRB5
int krb_forwardable;
#endif /* KRB5 */
char *krb_lifetime;
+#ifdef GSSAPI
+ int krb_method_gssapi;
+#endif /* GSSAPI */
+#ifdef KRB4
+ int krb_method_k4pass;
+#endif /* KRB4 */
#ifdef KRB5
+ int krb_method_k5pass;
char *krb_renewable;
#endif /* KRB5 */
int krb_save_credentials;
char *service_name;
} kerb_auth_config;
+
+
+
+/***************************************************************************
+ GSSAPI Support Initialization
+ ***************************************************************************/
+#ifdef GSSAPI
typedef struct {
gss_ctx_id_t context;
gss_cred_id_t server_creds;
if (gss_conn->server_creds != GSS_C_NO_CREDENTIAL)
gss_release_cred(&minor_status, &gss_conn->server_creds);
}
+#endif /* GSSAPI */
+
rec = (void *) ap_pcalloc(p, sizeof(kerb_auth_config));
((kerb_auth_config *)rec)->krb_fail_status = HTTP_UNAUTHORIZED;
((kerb_auth_config *)rec)->krb_authoritative = 0;
- ((kerb_auth_config *)rec)->krb_auth_type = MK_PSTRDUP(p, "None");
+#ifdef GSSAPI
+ ((kerb_auth_config *)rec)->krb_method_gssapi = 0;
+#endif /* GSSAPI */
+#ifdef KRB4
+ ((kerb_auth_config *)rec)->krb_method_k4pass = 1;
+#endif /* KRB4 */
+#ifdef KRB5
+ ((kerb_auth_config *)rec)->krb_method_k5pass = 1;
+#ifdef KRB4
+ ((kerb_auth_config *)rec)->krb_method_k4pass = 0;
+#endif /* KRB4 */
+#endif /* KRB5 */
+ ((kerb_auth_config *)rec)->krb_auth_realms = "";
return rec;
}
return NULL;
}
-/* these are either char *struct_ptr, char *arg or void *struct_ptr, const char *arg */
-static const char *kerb_set_type_slot(cmd_parms *cmd, void *struct_ptr,
- const char *arg)
-{
- int offset = (int) (long) cmd->info;
-#ifdef KRB5
- if (!strncasecmp(arg, "v5", 2))
- *(char **) ((char *)struct_ptr + offset) = MK_PSTRDUP(cmd->pool, "KerberosV5");
- else
-#endif /* KRB5 */
-#ifdef KRB4
- if (!strncasecmp(arg, "v4", 2))
- *(char **) ((char *)struct_ptr + offset) = MK_PSTRDUP(cmd->pool, "KerberosV4");
- else
-#endif /* KRB4 */
- if (!strncasecmp(arg, "dualv5v4", 8))
- *(char **) ((char *)struct_ptr + offset) = MK_PSTRDUP(cmd->pool, "KerberosDualV5V4");
- else if
- (!strncasecmp(arg, "dualv4v5", 8))
- *(char **) ((char *)struct_ptr + offset) = MK_PSTRDUP(cmd->pool, "KerberosDualV4V5");
-#if defined(KRB4) && defined(KRB5)
-#endif /* KRB4 && KRB5 */
- else
- return "AuthKerberos must be V5, V4, DualV4V5, or DualV5V4.";
- return NULL;
-}
-
command_rec kerb_auth_cmds[] = {
{
"AuthKerberos",
- kerb_set_type_slot,
- (void*)XtOffsetOf(kerb_auth_config, krb_auth_type),
+ ap_set_flag_slot,
+ (void*)XtOffsetOf(kerb_auth_config, krb_auth_enable),
OR_AUTHCFG,
- TAKE1,
+ FLAG,
"Permit Kerberos auth without AuthType requirement."
},
},
{
- "KrbDefaultRealm",
+ "KrbAuthRealm",
ap_set_string_slot,
- (void*)XtOffsetOf(kerb_auth_config, krb_default_realm),
+ (void*)XtOffsetOf(kerb_auth_config, krb_auth_realms),
OR_AUTHCFG,
- TAKE1,
- "Default realm to authenticate users against."
+ ITERATE,
+ "Realms to attempt authentication against (can be multiple)."
},
{
"Lifetime of tickets retrieved."
},
+#ifdef GSSAPI
+ {
+ "KrbMethodGSSAPI",
+ ap_set_flag_slot,
+ (void*)XtOffsetOf(kerb_auth_config, krb_method_gssapi),
+ OR_AUTHCFG,
+ FLAG,
+ "Enable GSSAPI authentication."
+ },
+#endif /* GSSAPI */
+
+#ifdef KRB4
+ {
+ "KrbMethodK4Pass",
+ ap_set_flag_slot,
+ (void*)XtOffsetOf(kerb_auth_config, krb_method_k4pass),
+ OR_AUTHCFG,
+ FLAG,
+ "Enable Kerberos V4 password authentication."
+ },
+#endif /* KRB4 */
+
#ifdef KRB5
{
+ "KrbMethodK5Pass",
+ ap_set_flag_slot,
+ (void*)XtOffsetOf(kerb_auth_config, krb_method_k5pass),
+ OR_AUTHCFG,
+ FLAG,
+ "Enable Kerberos V5 password authentication."
+ },
+
+ {
"KrbRenewable",
ap_set_string_slot,
(void*)XtOffsetOf(kerb_auth_config, krb_renewable),
#else
#ifdef APXS2
static const command_rec kerb_auth_cmds[] = {
- AP_INIT_TAKE1(
+ AP_INIT_FLAG(
"AuthKerberos",
kerb_set_type_slot,
- (void*)APR_XtOffsetOf(kerb_auth_config, krb_auth_type),
+ (void*)APR_XtOffsetOf(kerb_auth_config, krb_auth_enable),
OR_AUTHCFG,
"Permit Kerberos auth without AuthType requirement."
),
"Refuse to pass request down to lower modules."
),
- AP_INIT_TAKE1(
- "KrbDefaultRealm",
+ AP_INIT_ITERATE(
+ "KrbAuthRealm",
ap_set_string_slot,
- (void*)APR_XtOffsetOf(kerb_auth_config, krb_default_realm),
+ (void*)APR_XtOffsetOf(kerb_auth_config, krb_auth_realms),
OR_AUTHCFG,
- "Default realm to authenticate users against."
+ "Realm to attempt authentication against (can be multiple)."
),
AP_INIT_TAKE1(
"Lifetime of tickets retrieved."
),
+#ifdef GSSAPI
+ AP_INIT_FLAG(
+ "KrbMethodGSSAPI",
+ ap_set_flag_slot,
+ (void*)APR_XtOffsetOf(kerb_auth_config, krb_method_gssapi),
+ OR_AUTHCFG,
+ "Enable GSSAPI authentication."
+ ),
+#endif /* GSSAPI */
+
+#ifdef KRB4
+ AP_INIT_FLAG(
+ "KrbMethodK4Pass",
+ ap_set_flag_slot,
+ (void*)APR_XtOffsetOf(kerb_auth_config, krb_method_k4pass),
+ OR_AUTHCFG,
+ "Enable Kerberos V4 password authentication."
+ ),
+#endif /* KRB4 */
+
#ifdef KRB5
+ AP_INIT_FLAG(
+ "KrbMethodK5Pass",
+ ap_set_flag_slot,
+ (void*)APR_XtOffsetOf(kerb_auth_config, krb_method_k5pass),
+ OR_AUTHCFG,
+ "Enable Kerberos V5 password authentication."
+ ),
+
AP_INIT_TAKE1(
"KrbRenewable",
ap_set_string_slot,
#endif /* APXS1 */
+#ifndef HEIMDAL
+krb5_error_code
+krb5_verify_user(krb5_context context, krb5_principal principal,
+ krb5_ccache ccache, const char *password, krb5_boolean secure,
+ const char *service)
+{
+ int ret;
+ krb5_context kcontext;
+ krb5_principal server, client;
+ krb5_timestamp now;
+ krb5_creds my_creds;
+ krb5_flags options = 0;
+ krb5_principal me = NULL;
+ krb5_data tgtname = {
+ 0,
+ KRB5_TGS_NAME_SIZE,
+ KRB5_TGS_NAME
+ };
+
+ memset((char *)&my_creds, 0, sizeof(my_creds));
+ my_creds.client = principal;
+
+ if (krb5_build_principal_ext(kcontext, &server,
+ krb5_princ_realm(kcontext, me)->length,
+ krb5_princ_realm(kcontext, me)->data,
+ tgtname.length, tgtname.data,
+ krb5_princ_realm(kcontext, me)->length,
+ krb5_princ_realm(kcontext, me)->data,
+ 0)) {
+ return ret;
+ }
+
+ my_creds.server = server;
+ if (krb5_timeofday(kcontext, &now))
+ return -1;
+
+ my_creds.times.starttime = 0;
+ /* XXX
+ my_creds.times.endtime = now + lifetime;
+ my_creds.times.renew_till = now + renewal;
+ */
+
+ ret = krb5_get_in_tkt_with_password(kcontext, options, 0, NULL, 0,
+ password, ccache, &my_creds, 0);
+ if (ret) {
+ return ret;
+ }
+
+ return 0;
+}
+#endif
/***************************************************************************
Username/Password Validation
***************************************************************************/
#ifdef KRB5
+static void
+krb5_cache_cleanup(void *data)
+{
+ krb5_context context;
+ krb5_ccache cache;
+ krb5_error_code problem;
+ char *cache_name = (char *) data;
+
+ problem = krb5_init_context(&context);
+ if (problem) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, NULL, "krb5_init_context() failed");
+ return;
+ }
+
+ problem = krb5_cc_resolve(context, cache_name, &cache);
+ if (problem) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, NULL,
+ "krb5_cc_resolve() failed (%s: %s)",
+ cache_name, krb5_get_err_text(context, problem));
+ return;
+ }
+
+ krb5_cc_destroy(context, cache);
+ krb5_free_context(context);
+}
+
+static int
+store_krb5_creds(krb5_context kcontext,
+ request_rec *r,
+ kerb_auth_config *conf,
+ krb5_ccache delegated_cred)
+{
+ char *c, ccname[MAX_STRING_LEN];
+ krb5_error_code problem;
+ char errstr[1024];
+ int ret;
+ krb5_ccache ccache = NULL;
+ krb5_principal me = NULL;
+
+ sprintf(ccname, "FILE:%s/k5cc_ap_%s",
+ conf->krb_tmp_dir ? conf->krb_tmp_dir : "/tmp",
+ MK_USER);
+
+ for (c = ccname + strlen(conf->krb_tmp_dir ? conf->krb_tmp_dir :
+ "/tmp") + 1; *c; c++) {
+ if (*c == '/')
+ *c = '.';
+ }
+
+ problem = krb5_cc_set_default_name(kcontext, ccname);
+ if (problem) {
+ snprintf(errstr, sizeof(errstr),
+ "krb5_cc_set_default_name() failed: %s",
+ krb5_get_err_text(kcontext, problem));
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
+ goto end;
+ }
+#if 0
+ /* XXX Dan: Why is this done? Cleanup? But the file would not be
+ * accessible from another processes (CGI) */
+ unlink(ccname+strlen("FILE:"));
+#endif
+
+ problem = krb5_cc_resolve(kcontext, ccname, &ccache);
+ if (problem) {
+ snprintf(errstr, sizeof(errstr),
+ "krb5_cc_resolve() failed: %s",
+ krb5_get_err_text(kcontext, problem));
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
+ goto end;
+ }
+
+ problem = krb5_cc_get_principal(kcontext, delegated_cred, &me);
+ if (problem) {
+ snprintf(errstr, sizeof(errstr),
+ "krb5_cc_get_principal() failed: %s",
+ krb5_get_err_text(kcontext, problem));
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
+ goto end;
+ }
+
+ problem = krb5_cc_initialize(kcontext, ccache, me);
+ if (problem) {
+ snprintf(errstr, sizeof(errstr),
+ "krb5_cc_initialize() failed: %s",
+ krb5_get_err_text(kcontext, problem));
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
+ goto end;
+ }
+
+ problem = krb5_cc_copy_cache(kcontext, delegated_cred, ccache);
+ if (problem) {
+ snprintf(errstr, sizeof(errstr),
+ "krb5_cc_copy_cache failed: %s",
+ krb5_get_err_text(kcontext, problem));
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
+ goto end;
+ }
+ ap_table_setn(r->subprocess_env, "KRB5CCNAME", ccname);
+ ap_register_cleanup(r->pool, ccname,
+ krb5_cache_cleanup, ap_null_cleanup);
+
+ krb5_cc_close(kcontext, ccache);
+
+ ret = OK;
+
+end:
+
+ return ret; /* XXX */
+}
+
int kerb5_password_validate(request_rec *r, const char *user, const char *pass)
{
+
kerb_auth_config *conf =
(kerb_auth_config *)ap_get_module_config(r->per_dir_config,
&kerb_auth_module);
int ret;
krb5_context kcontext;
- krb5_principal server, me;
- krb5_creds my_creds;
- krb5_timestamp now;
+ krb5_principal client;
krb5_ccache ccache = NULL;
krb5_deltat lifetime = 300; /* 5 minutes */
krb5_deltat renewal = 0;
krb5_flags options = 0;
- krb5_data tgtname = {
-#ifndef HEIMDAL
- 0,
-#endif
- KRB5_TGS_NAME_SIZE,
- KRB5_TGS_NAME
- };
- char *c, ccname[MAX_STRING_LEN];
-
- if (krb5_init_context(&kcontext))
+ char errstr[1024];
+ krb5_error_code code;
+ const char *realms;
+
+ if (krb5_init_context(&kcontext)) {
+ snprintf(errstr, sizeof(errstr),
+ "Cannot initialize Kerberos5 context");
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
return 0;
+ }
- if (conf->krb_save_credentials) {
- lifetime = 1800; /* 30 minutes */
-
- if (conf->krb_forwardable) {
- options |= KDC_OPT_FORWARDABLE;
- }
-
- if (conf->krb_renewable) {
- options |= KDC_OPT_RENEWABLE;
- renewal = 86400; /* 24 hours */
- }
-
- sprintf(ccname, "FILE:%s/k5cc_ap_%s",
- conf->krb_tmp_dir ? conf->krb_tmp_dir : "/tmp",
- MK_USER);
-
- for (c = ccname + strlen(conf->krb_tmp_dir ? conf->krb_tmp_dir :
- "/tmp") + 1; *c; c++) {
- if (*c == '/')
- *c = '.';
- }
+ if (conf->krb_forwardable) {
+ options |= KDC_OPT_FORWARDABLE;
+ }
- ap_table_setn(r->subprocess_env, "KRB5CCNAME", ccname);
- if (krb5_cc_set_default_name(kcontext, ccname)) {
- return 0;
- }
- unlink(ccname+strlen("FILE:"));
+ if (conf->krb_renewable) {
+ options |= KDC_OPT_RENEWABLE;
+ renewal = 86400; /* 24 hours */
}
if (conf->krb_lifetime) {
- lifetime = atoi(conf->krb_lifetime);
+ lifetime = atoi(conf->krb_lifetime);
}
- memset((char *)&my_creds, 0, sizeof(my_creds));
- if(krb5_parse_name(kcontext, user, &me))
- return 0;
- my_creds.client = me;
-
#ifdef HEIMDAL
+ code = krb5_cc_gen_new(kcontext, &krb5_mcc_ops, &ccache);
#else
- if (krb5_build_principal_ext(kcontext, &server,
- krb5_princ_realm(kcontext, me)->length,
- krb5_princ_realm(kcontext, me)->data,
- tgtname.length, tgtname.data,
- krb5_princ_realm(kcontext, me)->length,
- krb5_princ_realm(kcontext, me)->data,
- 0)) {
- return 0;
- }
+ code = krb5_mcc_generate_new(kcontext, &ccache);
#endif
- my_creds.server = server;
- if (krb5_timeofday(kcontext, &now))
- return 0;
- my_creds.times.starttime = 0;
- my_creds.times.endtime = now + lifetime;
- my_creds.times.renew_till = now + renewal;
-
- if (conf->krb_save_credentials) {
- if (krb5_cc_resolve(kcontext, ccname, &ccache))
- return 0;
+ if (code) {
+ snprintf(errstr, sizeof(errstr), "Cannot generate new ccache: %.100s",
+ krb5_get_err_text(kcontext, code));
+ ap_log_reason (errstr, r->uri, r);
+ ret = SERVER_ERROR;
+ goto end;
+ }
- if (krb5_cc_initialize(kcontext, ccache, me))
- return 0;
+ realms = conf->krb_auth_realms;
+ do {
+ code = 0;
+ if (realms) {
+ code = krb5_set_default_realm(kcontext,
+ ap_getword_white(r->pool, &realms));
+ if (code)
+ continue;
+ }
+
+ code = krb5_parse_name(kcontext, r->connection->user, &client);
+ if (code)
+ continue;
+
+ code = krb5_verify_user(kcontext, client, ccache, pass,
+ 1, "khttp");
+ krb5_free_principal(kcontext, client);
+ if (code == 0)
+ break;
+
+ /* ap_getword_white() used above shifts the parameter, so it's not
+ needed to touch the realms variable */
+ } while (realms && *realms);
+
+ memset((char *)pass, 0, strlen(pass));
+
+ if (code) {
+ snprintf(errstr, sizeof(errstr), "Verifying krb5 password failed: %s",
+ krb5_get_err_text(kcontext, code));
+ ap_log_reason (errstr, r->uri, r);
+ ret = HTTP_UNAUTHORIZED;
+ goto end;
}
- ret = krb5_get_in_tkt_with_password(kcontext, options, 0, NULL, 0,
- pass, ccache, &my_creds, 0);
- if (ret) {
- return 0;
+ if (conf->krb_save_credentials) {
+ ret = store_krb5_creds(kcontext, r, conf, ccache);
+ if (ret)
+ goto end;
}
- krb5_free_cred_contents(kcontext, &my_creds);
+ ret = 1; /* XXX should be OK ? */
+
+end:
+ if (ccache)
+ krb5_cc_destroy(kcontext, ccache);
+ krb5_free_context(kcontext);
- return 1;
+ return (ret != 1) ? 0 : 1; /* XXX */
}
#endif /* KRB5 */
}
#endif /* KRB4 */
+
+
+
+/***************************************************************************
+ GSSAPI Validation
+ ***************************************************************************/
+#ifdef GSSAPI
+static const char *
+get_gss_error(pool *p, OM_uint32 error_status, char *prefix)
+{
+ OM_uint32 maj_stat, min_stat;
+ OM_uint32 msg_ctx = 0;
+ gss_buffer_desc status_string;
+ char buf[1024];
+ size_t len;
+
+ snprintf(buf, sizeof(buf), "%s: ", prefix);
+ len = strlen(buf);
+ do {
+ maj_stat = gss_display_status (&min_stat,
+ error_status,
+ GSS_C_MECH_CODE,
+ GSS_C_NO_OID,
+ &msg_ctx,
+ &status_string);
+ if (sizeof(buf) > len + status_string.length + 1) {
+ sprintf(buf+len, "%s:", (char*) status_string.value);
+ len += status_string.length;
+ }
+ gss_release_buffer(&min_stat, &status_string);
+ } while (!GSS_ERROR(maj_stat) && msg_ctx != 0);
+
+ return (ap_pstrdup(p, buf));
+}
+
static int
get_gss_creds(request_rec *r,
kerb_auth_config *conf,
gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
const char *auth_param = NULL;
- krb5_context krb_ctx = NULL;
int ret;
gss_name_t client_name = GSS_C_NO_NAME;
gss_cred_id_t delegated_cred = GSS_C_NO_CREDENTIAL;
- char *p;
if (gss_connection == NULL) {
gss_connection = ap_pcalloc(r->connection->pool, sizeof(*gss_connection));
if (gss_connection == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
- "ap_pcalloc() failed");
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
+ "ap_pcalloc() failed (not enough memory)");
ret = SERVER_ERROR;
goto end;
}
/* ap_getword() shifts parameter */
auth_param = ap_getword_white(r->pool, &auth_line);
if (auth_param == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
- "No Authorization parameter from client");
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
+ "No Authorization parameter in request from client");
ret = HTTP_UNAUTHORIZED;
goto end;
}
input_token.length = ap_base64decode_len(auth_param);
input_token.value = ap_pcalloc(r->connection->pool, input_token.length);
if (input_token.value == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
- "Not enough memory");
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
+ "ap_pcalloc() failed (not enough memory)");
ret = SERVER_ERROR;
goto end;
}
len = ap_base64encode_len(output_token.length);
token = ap_pcalloc(r->connection->pool, len + 1);
if (token == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
- "Not enough memory");
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
+ "ap_pcalloc() failed (not enough memory)");
ret = SERVER_ERROR;
gss_release_buffer(&minor_status2, &output_token);
goto end;
token[len] = '\0';
ap_table_set(r->err_headers_out, "WWW-Authenticate",
ap_pstrcat(r->pool, "GSS-Negotiate ", token, NULL));
- free(token);
gss_release_buffer(&minor_status2, &output_token);
}
if (GSS_ERROR(major_status)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"%s", get_gss_error(r->pool, minor_status,
"gss_accept_sec_context() failed"));
ret = HTTP_UNAUTHORIZED;
}
if (major_status & GSS_S_CONTINUE_NEEDED) {
-#if 0
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
- "only one authentication iteration allowed");
-#endif
+ /* Some GSSAPI mechanism (eg GSI from Globus) may require multiple
+ * iterations to establish authentication */
ret = HTTP_UNAUTHORIZED;
goto end;
}
major_status = gss_export_name(&minor_status, client_name, &output_token);
gss_release_name(&minor_status, &client_name);
if (GSS_ERROR(major_status)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"%s", get_gss_error(r->pool, minor_status,
"gss_export_name() failed"));
ret = SERVER_ERROR;
return ret;
}
+#endif /* GSSAPI */
+
+
/***************************************************************************
{
const char *name; /* AuthName specified */
const char *type; /* AuthType specified */
- int KerberosV5 = 0; /* Kerberos V5 check enabled */
- int KerberosV4 = 0; /* Kerberos V4 check enabled */
- int KerberosV4first = 0; /* Kerberos V4 check first */
const char *sent_pw; /* Password sent by browser */
int res; /* Response holder */
int retcode; /* Return code holder */
type = ap_auth_type(r);
- if (type != NULL) {
-#ifdef KRB5
- if ((strncasecmp(type, "KerberosV5", 10) == 0) ||
- (strncasecmp(conf->krb_auth_type, "KerberosV5", 10) == 0)) {
- KerberosV5 = 1;
- }
-#endif /* KRB5 */
-
-#ifdef KRB4
- if ((strncasecmp(type, "KerberosV4", 10) == 0) ||
- (strncasecmp(conf->krb_auth_type, "KerberosV4", 10) == 0)) {
- KerberosV4 = 1;
- }
-#endif /* KRB4 */
-
-#if defined(KRB5) && defined(KRB4)
- if ((strncasecmp(type, "KerberosDualV5V4", 15) == 0) ||
- (strncasecmp(conf->krb_auth_type, "KerberosDualV5V4", 15) == 0)) {
- KerberosV5 = 1;
- KerberosV4 = 1;
- }
-
- if ((strncasecmp(type, "KerberosDualV4V5", 15) == 0) ||
- (strncasecmp(conf->krb_auth_type, "KerberosDualV4V5", 15) == 0)) {
- KerberosV5 = 1;
- KerberosV4 = 1;
- KerberosV4first = 1;
- }
-#endif /* KRB5 && KRB4 */
- }
-
- if (!KerberosV4 && !KerberosV5) {
+ if (!conf->krb_auth_enable &&
+ (type == NULL || (strncasecmp(type, "Kerberos", 8) != 0))) {
if (conf->krb_authoritative) {
return HTTP_UNAUTHORIZED;
}
retcode = DECLINED;
+#ifdef GSSAPI
+ if (conf->krb_method_gssapi && retcode != OK) {
+ MK_AUTH_TYPE = "Negotiate";
+ if (negotiate_authenticate_user(r, conf, auth_line))
+ retcode = OK;
+ else
+ retcode = conf->krb_fail_status;
+ }
+#endif /* GSSAPI */
+
#ifdef KRB5
- if (KerberosV5 && !KerberosV4first && retcode != OK) {
+ if (conf->krb_method_k5pass && retcode != OK) {
MK_AUTH_TYPE = "KerberosV5";
if (kerb5_password_validate(r, MK_USER, sent_pw)) {
retcode = OK;
}
else {
retcode = conf->krb_fail_status;
+ /* XXX should SERVER_ERROR be overriden too? */
}
}
#endif /* KRB5 */
#ifdef KRB4
- if (KerberosV4 && retcode != OK) {
+ if (conf->krb_method_k4pass && retcode != OK) {
MK_AUTH_TYPE = "KerberosV4";
if (kerb4_password_validate(r, MK_USER, sent_pw)) {
retcode = OK;
}
#endif /* KRB4 */
-#if defined(KRB5) && defined(KRB4)
- if (KerberosV5 && KerberosV4first && retcode != OK) {
- MK_AUTH_TYPE = "KerberosV5";
- if (kerb5_password_validate(r, MK_USER, sent_pw)) {
- retcode = OK;
- }
- else {
- retcode = conf->krb_fail_status;
- }
- }
-#endif /* KRB5 && KRB4 */
-
if (conf->krb_authoritative && retcode == DECLINED) {
return HTTP_UNAUTHORIZED;
}