mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-24 18:29:03 +00:00
Drop AuthorityReactiveAuthorizationManager and avoid need to block
See gh-11869
This commit is contained in:
+9
-4
@@ -42,8 +42,8 @@ import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicat
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authorization.AuthorityReactiveAuthorizationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -402,11 +402,16 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
if (this.authentication == null) {
|
||||
if (this.authentication == null || !this.authentication.isAuthenticated()) {
|
||||
return false;
|
||||
}
|
||||
return AuthorityReactiveAuthorizationManager.hasRole(role)
|
||||
.check(Mono.just(this.authentication), null).block().isGranted();
|
||||
for (GrantedAuthority grantedAuthority : this.authentication
|
||||
.getAuthorities()) {
|
||||
if (role.equals(grantedAuthority.getAuthority())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user