1 int kerb_authenticate_user(request_rec *r) {
2 const char *type; /* AuthType specified */
3 int KerberosV5 = 0; /* Kerberos V5 check enabled */
4 int KerberosV4 = 0; /* Kerberos V4 check enabled */
5 const char *sent_pw; /* Password sent by browser */
6 const char *t; /* Return value holder */
7 int res; /* Response holder */
9 const char *auth_line = apr_table_get(r->headers_in,
10 (PROXYREQ_PROXY == r->proxyreq)
11 ? "Proxy-Authorization"
14 type = ap_auth_type(r);
18 if (strncasecmp(type, "KerberosV5", 10) == 0) {
24 if (strncasecmp(type, "KerberosV4", 10) == 0) {
30 if (!KerberosV4 && !KerberosV5) {
34 if (!ap_auth_name(r)) {
35 ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
36 0, r, "need AuthName: %s", r->uri);
37 return HTTP_INTERNAL_SERVER_ERROR;
41 ap_note_basic_auth_failure(r);
42 return HTTP_UNAUTHORIZED;
45 if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) {
46 /* Client tried to authenticate using wrong auth scheme */
47 ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
48 "client used wrong authentication scheme: %s", r->uri);
49 ap_note_basic_auth_failure(r);
50 return HTTP_UNAUTHORIZED;
53 while (*auth_line == ' ' || *auth_line == '\t') {
57 t = ap_pbase64decode(r->pool, auth_line);
58 r->user = ap_getword_nulls(r->pool, &t, ':');
63 r->ap_auth_type = "KerberosV5";
64 if (kerb5_password_validate(r->user, sent_pw)) {
68 return HTTP_UNAUTHORIZED;
74 r->ap_auth_type = "KerberosV4";
75 if (kerb4_password_validate(r->user, sent_pw)) {
79 return HTTP_UNAUTHORIZED;