Class SpringAccessPathChecker
- All Implemented Interfaces:
AccessPathChecker,Serializable
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- Since:
- 25.4
-
-
Method Details
-
hasAccess
Description copied from interface:AccessPathCheckerChecks if the user defined by the givenPrincipaland role checker has access to the given path.The
pathis relative to the Vaadin application and does not contain any container specific details such as context or servlet path.The
pathis never null and never starts with a "/" character.- Specified by:
hasAccessin interfaceAccessPathChecker- Parameters:
path- the path to check access toprincipal- the principal of the user, or null if the check must be done for an anonymous user. A null value must be treated as anonymous even if an authenticated user is bound to the current thread, e.g. when checking whether a path is publicroleChecker- a function that can answer if a user has a given role- Returns:
trueif the user has access to the given path,falseotherwise.
-