Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5a7f12f

Browse filesBrowse files
Check for null Authentication
Closes gh-14715
1 parent c614422 commit 5a7f12f
Copy full SHA for 5a7f12f

File tree

2 files changed

+4
-1
lines changed
Filter options

2 files changed

+4
-1
lines changed

‎core/src/main/java/org/springframework/security/access/vote/AuthenticatedVoter.java

Copy file name to clipboardExpand all lines: core/src/main/java/org/springframework/security/access/vote/AuthenticatedVoter.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class AuthenticatedVoter implements AccessDecisionVoter<Object> {
5757
private AuthenticationTrustResolver authenticationTrustResolver = new AuthenticationTrustResolverImpl();
5858

5959
private boolean isFullyAuthenticated(Authentication authentication) {
60-
return (!this.authenticationTrustResolver.isAnonymous(authentication)
60+
return authentication != null && (!this.authenticationTrustResolver.isAnonymous(authentication)
6161
&& !this.authenticationTrustResolver.isRememberMe(authentication));
6262
}
6363

‎core/src/test/java/org/springframework/security/access/vote/AuthenticatedVoterTests.java

Copy file name to clipboardExpand all lines: core/src/test/java/org/springframework/security/access/vote/AuthenticatedVoterTests.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void testAnonymousWorks() {
5959
assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(voter.vote(createAnonymous(), null, def));
6060
assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(voter.vote(createRememberMe(), null, def));
6161
assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(voter.vote(createFullyAuthenticated(), null, def));
62+
assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(voter.vote(null, null, def));
6263
}
6364

6465
@Test
@@ -68,6 +69,7 @@ public void testFullyWorks() {
6869
assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(voter.vote(createAnonymous(), null, def));
6970
assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(voter.vote(createRememberMe(), null, def));
7071
assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(voter.vote(createFullyAuthenticated(), null, def));
72+
assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(voter.vote(null, null, def));
7173
}
7274

7375
@Test
@@ -77,6 +79,7 @@ public void testRememberMeWorks() {
7779
assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(voter.vote(createAnonymous(), null, def));
7880
assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(voter.vote(createRememberMe(), null, def));
7981
assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(voter.vote(createFullyAuthenticated(), null, def));
82+
assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(voter.vote(null, null, def));
8083
}
8184

8285
@Test

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.