Update oauth2-resourceserver.adoc
fix the name of the parameter, from failure to badCredentials Replaces AuthenticationFailureEvent Remove AuthenticationFailureEvent Reference Closes gh-10062
This commit is contained in:
parent
36454d3f91
commit
a4431264e6
|
@ -1,7 +1,7 @@
|
||||||
[[servlet-events]]
|
[[servlet-events]]
|
||||||
== Authentication Events
|
== Authentication Events
|
||||||
|
|
||||||
For each authentication that succeeds or fails, a `AuthenticationSuccessEvent` or `AuthenticationFailureEvent` is fired, respectively.
|
For each authentication that succeeds or fails, a `AuthenticationSuccessEvent` or `AbstractAuthenticationFailureEvent` is fired, respectively.
|
||||||
|
|
||||||
To listen for these events, you must first publish an `AuthenticationEventPublisher`.
|
To listen for these events, you must first publish an `AuthenticationEventPublisher`.
|
||||||
Spring Security's `DefaultAuthenticationEventPublisher` will probably do fine:
|
Spring Security's `DefaultAuthenticationEventPublisher` will probably do fine:
|
||||||
|
@ -42,7 +42,7 @@ public class AuthenticationEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onFailure(AuthenticationFailureEvent failures) {
|
public void onFailure(AbstractAuthenticationFailureEvent failures) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ While similar to `AuthenticationSuccessHandler` and `AuthenticationFailureHandle
|
||||||
|
|
||||||
=== Adding Exception Mappings
|
=== Adding Exception Mappings
|
||||||
|
|
||||||
`DefaultAuthenticationEventPublisher` by default will publish an `AuthenticationFailureEvent` for the following events:
|
`DefaultAuthenticationEventPublisher` by default will publish an `AbstractAuthenticationFailureEvent` for the following events:
|
||||||
|
|
||||||
|============
|
|============
|
||||||
| Exception | Event
|
| Exception | Event
|
||||||
|
@ -97,7 +97,7 @@ To that end, you may want to supply additional mappings to the publisher via the
|
||||||
public AuthenticationEventPublisher authenticationEventPublisher
|
public AuthenticationEventPublisher authenticationEventPublisher
|
||||||
(ApplicationEventPublisher applicationEventPublisher) {
|
(ApplicationEventPublisher applicationEventPublisher) {
|
||||||
Map<Class<? extends AuthenticationException>,
|
Map<Class<? extends AuthenticationException>,
|
||||||
Class<? extends AuthenticationFailureEvent>> mapping =
|
Class<? extends AbstractAuthenticationFailureEvent>> mapping =
|
||||||
Collections.singletonMap(FooException.class, FooEvent.class);
|
Collections.singletonMap(FooException.class, FooEvent.class);
|
||||||
AuthenticationEventPublisher authenticationEventPublisher =
|
AuthenticationEventPublisher authenticationEventPublisher =
|
||||||
new DefaultAuthenticationEventPublisher(applicationEventPublisher);
|
new DefaultAuthenticationEventPublisher(applicationEventPublisher);
|
||||||
|
|
|
@ -3038,7 +3038,7 @@ Additionally, it is published as an `AuthenticationFailureBadCredentialsEvent`,
|
||||||
@Component
|
@Component
|
||||||
public class FailureEvents {
|
public class FailureEvents {
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onFailure(AuthenticationFailureEvent failure) {
|
public void onFailure(AuthenticationFailureBadCredentialsEvent badCredentials) {
|
||||||
if (badCredentials.getAuthentication() instanceof BearerTokenAuthenticationToken) {
|
if (badCredentials.getAuthentication() instanceof BearerTokenAuthenticationToken) {
|
||||||
// ... handle
|
// ... handle
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue