Skip to content

Commit f13d8d5

Browse files
committed
Fix Nullability in WebInvocationPrivilegeEvaluator
Issue gh-17535
1 parent 1216ee5 commit f13d8d5

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

web/src/main/java/org/springframework/security/web/access/AuthorizationManagerWebInvocationPrivilegeEvaluator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public AuthorizationManagerWebInvocationPrivilegeEvaluator(
5050
}
5151

5252
@Override
53-
public boolean isAllowed(String uri, Authentication authentication) {
53+
public boolean isAllowed(String uri, @Nullable Authentication authentication) {
5454
return isAllowed(null, uri, null, authentication);
5555
}
5656

5757
@Override
5858
public boolean isAllowed(@Nullable String contextPath, String uri, @Nullable String method,
59-
Authentication authentication) {
59+
@Nullable Authentication authentication) {
6060
FilterInvocation filterInvocation = new FilterInvocation(contextPath, uri, method, this.servletContext);
6161
HttpServletRequest httpRequest = this.requestTransformer.transform(filterInvocation.getHttpRequest());
6262
AuthorizationResult result = this.authorizationManager.authorize(() -> authentication, httpRequest);

web/src/main/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public DefaultWebInvocationPrivilegeEvaluator(AbstractSecurityInterceptor securi
6565
* be used)
6666
*/
6767
@Override
68-
public boolean isAllowed(String uri, Authentication authentication) {
68+
public boolean isAllowed(String uri, @Nullable Authentication authentication) {
6969
return isAllowed(null, uri, null, authentication);
7070
}
7171

@@ -88,7 +88,7 @@ public boolean isAllowed(String uri, Authentication authentication) {
8888
*/
8989
@Override
9090
public boolean isAllowed(@Nullable String contextPath, String uri, @Nullable String method,
91-
Authentication authentication) {
91+
@Nullable Authentication authentication) {
9292
Assert.notNull(uri, "uri parameter is required");
9393
FilterInvocation filterInvocation = new FilterInvocation(contextPath, uri, method, this.servletContext);
9494
Collection<ConfigAttribute> attributes = this.securityInterceptor.obtainSecurityMetadataSource()

web/src/main/java/org/springframework/security/web/access/RequestMatcherDelegatingWebInvocationPrivilegeEvaluator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public RequestMatcherDelegatingWebInvocationPrivilegeEvaluator(
7373
* @return true if access is allowed, false if denied
7474
*/
7575
@Override
76-
public boolean isAllowed(String uri, Authentication authentication) {
76+
public boolean isAllowed(String uri, @Nullable Authentication authentication) {
7777
List<WebInvocationPrivilegeEvaluator> privilegeEvaluators = getDelegate(null, uri, null);
7878
if (privilegeEvaluators.isEmpty()) {
7979
return true;
@@ -106,7 +106,8 @@ public boolean isAllowed(String uri, Authentication authentication) {
106106
* @return true if access is allowed, false if denied
107107
*/
108108
@Override
109-
public boolean isAllowed(String contextPath, String uri, String method, Authentication authentication) {
109+
public boolean isAllowed(String contextPath, String uri, @Nullable String method,
110+
@Nullable Authentication authentication) {
110111
List<WebInvocationPrivilegeEvaluator> privilegeEvaluators = getDelegate(contextPath, uri, method);
111112
if (privilegeEvaluators.isEmpty()) {
112113
return true;

web/src/main/java/org/springframework/security/web/access/WebInvocationPrivilegeEvaluator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.web.access;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.security.core.Authentication;
2022

2123
/**
@@ -35,7 +37,7 @@ public interface WebInvocationPrivilegeEvaluator {
3537
* @param uri the URI excluding the context path (a default context path setting will
3638
* be used)
3739
*/
38-
boolean isAllowed(String uri, Authentication authentication);
40+
boolean isAllowed(String uri, @Nullable Authentication authentication);
3941

4042
/**
4143
* Determines whether the user represented by the supplied <tt>Authentication</tt>
@@ -58,6 +60,6 @@ public interface WebInvocationPrivilegeEvaluator {
5860
* be used in evaluation whether access should be granted.
5961
* @return true if access is allowed, false if denied
6062
*/
61-
boolean isAllowed(String contextPath, String uri, String method, Authentication authentication);
63+
boolean isAllowed(String contextPath, String uri, @Nullable String method, @Nullable Authentication authentication);
6264

6365
}

0 commit comments

Comments
 (0)