Skip to content

Commit 5fcbb9f

Browse files
Karthikeyan Rjzheaux
authored andcommitted
Add AuthenticationTrustResolver#isFullyAuthenticated
Closes gh-11510
1 parent eb57d9e commit 5fcbb9f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

core/src/main/java/org/springframework/security/access/expression/SecurityExpressionRoot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public final boolean isRememberMe() {
153153
@Override
154154
public final boolean isFullyAuthenticated() {
155155
Authentication authentication = getAuthentication();
156-
return !this.trustResolver.isAnonymous(authentication) && !this.trustResolver.isRememberMe(authentication);
156+
return this.trustResolver.isFullyAuthenticated(authentication);
157157
}
158158

159159
/**

core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolver.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,21 @@ public interface AuthenticationTrustResolver {
5353
*/
5454
boolean isRememberMe(Authentication authentication);
5555

56+
/**
57+
* Indicates whether the passed <code>Authentication</code> token represents a fully
58+
* authenticated user (that is, neither anonymous or remember-me). This is a
59+
* composition of <code>isAnonymous</code> and <code>isRememberMe</code>
60+
* implementation
61+
* <p>
62+
* @param authentication to test (may be <code>null</code> in which case the method
63+
* will always return <code>false</code>)
64+
* @return <code>true</code> the passed authentication token represented an anonymous
65+
* principal & is authenticated using a remember-me token, <code>false</code>
66+
* otherwise
67+
* @since 5.8
68+
*/
69+
default boolean isFullyAuthenticated(Authentication authentication) {
70+
return !isAnonymous(authentication) && !isRememberMe(authentication);
71+
}
72+
5673
}

core/src/main/java/org/springframework/security/authorization/AuthenticatedAuthorizationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static final class FullyAuthenticatedAuthorizationStrategy extends Authe
143143

144144
@Override
145145
boolean isGranted(Authentication authentication) {
146-
return super.isGranted(authentication) && !this.trustResolver.isRememberMe(authentication);
146+
return authentication != null && this.trustResolver.isFullyAuthenticated(authentication);
147147
}
148148

149149
}

0 commit comments

Comments
 (0)