mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-29 15:22:15 +00:00
Add AuthenticationTrustResolver#isFullyAuthenticated
Closes gh-11510
This commit is contained in:
parent
eb57d9e5c1
commit
5fcbb9f4ed
@ -153,7 +153,7 @@ public abstract class SecurityExpressionRoot implements SecurityExpressionOperat
|
|||||||
@Override
|
@Override
|
||||||
public final boolean isFullyAuthenticated() {
|
public final boolean isFullyAuthenticated() {
|
||||||
Authentication authentication = getAuthentication();
|
Authentication authentication = getAuthentication();
|
||||||
return !this.trustResolver.isAnonymous(authentication) && !this.trustResolver.isRememberMe(authentication);
|
return this.trustResolver.isFullyAuthenticated(authentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,4 +53,21 @@ public interface AuthenticationTrustResolver {
|
|||||||
*/
|
*/
|
||||||
boolean isRememberMe(Authentication authentication);
|
boolean isRememberMe(Authentication authentication);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the passed <code>Authentication</code> token represents a fully
|
||||||
|
* authenticated user (that is, neither anonymous or remember-me). This is a
|
||||||
|
* composition of <code>isAnonymous</code> and <code>isRememberMe</code>
|
||||||
|
* implementation
|
||||||
|
* <p>
|
||||||
|
* @param authentication to test (may be <code>null</code> in which case the method
|
||||||
|
* will always return <code>false</code>)
|
||||||
|
* @return <code>true</code> the passed authentication token represented an anonymous
|
||||||
|
* principal & is authenticated using a remember-me token, <code>false</code>
|
||||||
|
* otherwise
|
||||||
|
* @since 5.8
|
||||||
|
*/
|
||||||
|
default boolean isFullyAuthenticated(Authentication authentication) {
|
||||||
|
return !isAnonymous(authentication) && !isRememberMe(authentication);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public final class AuthenticatedAuthorizationManager<T> implements Authorization
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isGranted(Authentication authentication) {
|
boolean isGranted(Authentication authentication) {
|
||||||
return super.isGranted(authentication) && !this.trustResolver.isRememberMe(authentication);
|
return authentication != null && this.trustResolver.isFullyAuthenticated(authentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user