Drop AuthorityReactiveAuthorizationManager and avoid need to block

See gh-11869
pull/12149/head
Andy Wilkinson 7 years ago
parent 45476961c1
commit daa280faff

@ -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;
}
}

Loading…
Cancel
Save