Package com.vaadin.flow.spring.security
Class SpringAccessPathChecker
java.lang.Object
com.vaadin.flow.spring.security.SpringAccessPathChecker
- All Implemented Interfaces:
com.vaadin.flow.server.auth.AccessPathChecker,Serializable
public class SpringAccessPathChecker
extends Object
implements com.vaadin.flow.server.auth.AccessPathChecker
A Spring specific route path access checker that delegates the check to
Spring Security.
It is used in combination with
RoutePathAccessChecker to provide
path-based security to Flow
NavigationAccessControl.
To enable it, define a NavigationAccessControlConfigurer bean,
configured using
NavigationAccessControlConfigurer.withRoutePathAccessChecker()
method.
The current authentication is read from a
SecurityContextHolderStrategy. When the principal passed to
hasAccess(String, Principal, Predicate) is null, the
check is done for an anonymous user: an anonymous authentication from the
strategy is kept, any other authentication is replaced by a default
ROLE_ANONYMOUS one.
@Bean
NavigationAccessControlConfigurer navigationAccessControlConfigurer() {
return new NavigationAccessControlConfigurer()
.withRoutePathAccessChecker().withLoginView(LoginView.class);
}
- Since:
- 24.3
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions.SpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator, String urlMapping) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions.SpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator, String urlMapping, org.springframework.security.core.context.SecurityContextHolderStrategy securityContextHolderStrategy) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions. -
Method Summary
-
Constructor Details
-
SpringAccessPathChecker
public SpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions.The current authentication is read from the strategy installed in
SecurityContextHolder.- Parameters:
evaluator- evaluator to check path permissions.
-
SpringAccessPathChecker
public SpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator, String urlMapping) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions. It applies the given Vaadin servlet url mapping to the input path before delegating the check to the evaluator. The current authentication is read from the strategy installed inSecurityContextHolder.- Parameters:
evaluator- evaluator to check path permissions.urlMapping- Vaadin servlet url mapping
-
SpringAccessPathChecker
public SpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator, String urlMapping, org.springframework.security.core.context.SecurityContextHolderStrategy securityContextHolderStrategy) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions. It applies the given Vaadin servlet url mapping to the input path before delegating the check to the evaluator. The current authentication is read from the givenSecurityContextHolderStrategyinstead of the one installed inSecurityContextHolder.- Parameters:
evaluator- evaluator to check path permissions.urlMapping- Vaadin servlet url mappingsecurityContextHolderStrategy- the strategy to read the current authentication from, not null
-
-
Method Details
-
hasAccess
- Specified by:
hasAccessin interfacecom.vaadin.flow.server.auth.AccessPathChecker
-