Skip to content

Commit 4e7967e

Browse files
committed
Fix checks on allowed mechs
We need to check if a mech is allowed against the desired_mechs set. Otherwise in case the admin does not explicitly specify an allowed set then all mechs are allowed, including NTLM. This causes annoying issues with browsers like Firefox and Chrome/ium which end up popping up an authentication dialog if they see NTLM is supported and they have no Kerberos tickets around. Authentication will then simply fail because NTLM is not actually supported. By using desired_mechs we use a list of mechanism the machine actually has a chance to support in the default case. Signed-off-by: Simo Sorce <[email protected]>
1 parent 47de8ee commit 4e7967e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/mod_auth_gssapi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ static bool parse_auth_header(apr_pool_t *pool, const char **auth_header,
292292
return true;
293293
}
294294

295-
static bool is_mech_allowed(struct mag_config *cfg, gss_const_OID mech)
295+
static bool is_mech_allowed(gss_OID_set allowed_mechs, gss_const_OID mech)
296296
{
297-
if (cfg->allowed_mechs == GSS_C_NO_OID_SET) return true;
297+
if (allowed_mechs == GSS_C_NO_OID_SET) return true;
298298

299-
for (int i = 0; i < cfg->allowed_mechs->count; i++) {
300-
if (gss_oid_equal(&cfg->allowed_mechs->elements[i], mech)) {
299+
for (int i = 0; i < allowed_mechs->count; i++) {
300+
if (gss_oid_equal(&allowed_mechs->elements[i], mech)) {
301301
return true;
302302
}
303303
}
@@ -785,7 +785,7 @@ static int mag_auth(request_rec *req)
785785
break;
786786

787787
case AUTH_TYPE_RAW_NTLM:
788-
if (!is_mech_allowed(cfg, &gss_mech_ntlmssp)) {
788+
if (!is_mech_allowed(desired_mechs, &gss_mech_ntlmssp)) {
789789
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, req,
790790
"NTLM Authentication is not allowed!");
791791
goto done;
@@ -945,7 +945,7 @@ static int mag_auth(request_rec *req)
945945
}
946946
} else if (ret == HTTP_UNAUTHORIZED) {
947947
apr_table_add(req->err_headers_out, "WWW-Authenticate", "Negotiate");
948-
if (is_mech_allowed(cfg, &gss_mech_ntlmssp)) {
948+
if (is_mech_allowed(desired_mechs, &gss_mech_ntlmssp)) {
949949
apr_table_add(req->err_headers_out, "WWW-Authenticate", "NTLM");
950950
}
951951
if (cfg->use_basic_auth) {

0 commit comments

Comments
 (0)