1
0
mirror of synced 2026-08-05 09:47:05 +00:00

Add hasAnyAuthority() and hasAnyRole() in AuthorizeExchangeSpec

Fixes gh-6306
This commit is contained in:
Robbie Martinus
2018-12-19 22:36:30 +11:00
committed by Rob Winch
parent a919b4e916
commit e60ae4984a
3 changed files with 114 additions and 7 deletions
@@ -1563,6 +1563,15 @@ public class ServerHttpSecurity {
return access(AuthorityReactiveAuthorizationManager.hasRole(role));
}
/**
* Require any specific role. This is a shortcut for {@link #hasAnyAuthority(String...)}
* @param roles the roles (i.e. "USER" would require "ROLE_USER")
* @return the {@link AuthorizeExchangeSpec} to configure
*/
public AuthorizeExchangeSpec hasAnyRole(String... roles) {
return access(AuthorityReactiveAuthorizationManager.hasAnyRole(roles));
}
/**
* Require a specific authority.
* @param authority the authority to require (i.e. "USER" woudl require authority of "USER").
@@ -1572,6 +1581,15 @@ public class ServerHttpSecurity {
return access(AuthorityReactiveAuthorizationManager.hasAuthority(authority));
}
/**
* Require any authority
* @param authorities the authorities to require (i.e. "USER" would require authority of "USER").
* @return the {@link AuthorizeExchangeSpec} to configure
*/
public AuthorizeExchangeSpec hasAnyAuthority(String... authorities) {
return access(AuthorityReactiveAuthorizationManager.hasAnyAuthority(authorities));
}
/**
* Require an authenticated user
* @return the {@link AuthorizeExchangeSpec} to configure