Skip to content

Commit c8ac2a4

Browse files
iboukrissimo5
authored andcommitted
Avoid advertising NTLM if it isn't technically supported
This lets browsers to fall back to basic auth if supported (similar to 4e7967e). Add boolean param to is_mech_allowed which denotes whether the caller supports multiple step. Reviewed-by: Simo Sorce <simo@redhat.com>
1 parent 4e7967e commit c8ac2a4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/mod_auth_gssapi.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +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(gss_OID_set allowed_mechs, gss_const_OID mech)
295+
static bool is_mech_allowed(gss_OID_set allowed_mechs, gss_const_OID mech,
296+
bool multi_step_supported)
296297
{
298+
if (!multi_step_supported && gss_oid_equal(&gss_mech_ntlmssp, mech))
299+
return false;
300+
297301
if (allowed_mechs == GSS_C_NO_OID_SET) return true;
298302

299303
for (int i = 0; i < allowed_mechs->count; i++) {
@@ -785,7 +789,8 @@ static int mag_auth(request_rec *req)
785789
break;
786790

787791
case AUTH_TYPE_RAW_NTLM:
788-
if (!is_mech_allowed(desired_mechs, &gss_mech_ntlmssp)) {
792+
if (!is_mech_allowed(desired_mechs, &gss_mech_ntlmssp,
793+
cfg->gss_conn_ctx)) {
789794
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, req,
790795
"NTLM Authentication is not allowed!");
791796
goto done;
@@ -945,7 +950,8 @@ static int mag_auth(request_rec *req)
945950
}
946951
} else if (ret == HTTP_UNAUTHORIZED) {
947952
apr_table_add(req->err_headers_out, "WWW-Authenticate", "Negotiate");
948-
if (is_mech_allowed(desired_mechs, &gss_mech_ntlmssp)) {
953+
if (is_mech_allowed(desired_mechs, &gss_mech_ntlmssp,
954+
cfg->gss_conn_ctx)) {
949955
apr_table_add(req->err_headers_out, "WWW-Authenticate", "NTLM");
950956
}
951957
if (cfg->use_basic_auth) {

0 commit comments

Comments
 (0)