Skip to content

Commit 21fb5f9

Browse files
MartinEmrichsjohnr
authored andcommitted
Explain behaviour with XMLHttpRequest on 401 response
Relates to / Closes gh-16103
1 parent 86599af commit 21fb5f9

File tree

1 file changed

+9
-0
lines changed
  • docs/modules/ROOT/pages/servlet/authentication/passwords

1 file changed

+9
-0
lines changed

docs/modules/ROOT/pages/servlet/authentication/passwords/basic.adoc

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ image:{icondir}/number_3.png[] Since the user is not authenticated, xref:servlet
2222
The configured xref:servlet/authentication/architecture.adoc#servlet-authentication-authenticationentrypoint[`AuthenticationEntryPoint`] is an instance of javadoc:org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint[], which sends a WWW-Authenticate header.
2323
The `RequestCache` is typically a `NullRequestCache` that does not save the request since the client is capable of replaying the requests it originally requested.
2424

25+
[NOTE]
26+
====
27+
The default HTTP Basic Auth Provider will suppress both Response body and `WWW-Authenticate` header in the 401 response when
28+
the request was made with a `X-Requested-By: XMLHttpRequest` header. This allows frontends to implement their own
29+
authentication code, instead of triggering the browser login dialog.
30+
To override, implement your own
31+
javadoc:org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint[] .
32+
====
33+
2534
When a client receives the `WWW-Authenticate` header, it knows it should retry with a username and password.
2635
The following image shows the flow for the username and password being processed:
2736

0 commit comments

Comments
 (0)