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.
 
 
 @Bean
 NavigationAccessControlConfigurer navigationAccessControlConfigurer() {
     return new NavigationAccessControlConfigurer()
             .withRoutePathAccessChecker().withLoginView(LoginView.class);
 }
 
 
 Custom Request Transformer
 When using SpringAccessPathChecker with Spring Security request
 matchers that need to access
 HttpServletRequest.getUserPrincipal(), you may
 need to create a custom
 AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformer
 bean using
 principalAwareRequestTransformer(org.springframework.security.web.access.AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformer).
 This prevents UnsupportedOperationExceptions that can occur when
 Spring Security request matchers attempt to access user principal
 information.
 
 
 @Bean
 @Primary
 HttpServletRequestTransformer customRequestTransformer() {
     return SpringAccessPathChecker.principalAwareRequestTransformer(
             new PathPatternRequestTransformer());
 }
 
 
 An alternative is to use wrap the single request matchers using
 RequestUtil.principalAwareRequestMatcher(RequestMatcher).
 
 
 @Bean
 public SecurityFilterChain webFilterChain(HttpSecurity http) {
     http.authorizeRequests(cfg -> cfg.requestMatchers(RequestUtil.principalAwareRequestMatcher(
          request -> {
              ...
              if (request.getUserPrincipal() == null) {
                  ....;
              }
              ...
              return true;
          }
     ));
 }
 
 - 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. - 
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the user defined by the givenPrincipaland role checker has access to the given path.static org.springframework.security.web.access.AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformerprincipalAwareRequestTransformer(org.springframework.security.web.access.AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformer transformer) Provides a security-aware HTTP request transformer that applies additional processing to the transformed request usingRequestUtil.PrincipalAwareRequestWrapper. 
- 
Constructor Details
- 
SpringAccessPathChecker
public SpringAccessPathChecker(org.springframework.security.web.access.WebInvocationPrivilegeEvaluator evaluator) Creates a new instance that uses the givenWebInvocationPrivilegeEvaluatorto check path permissions.- 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.- Parameters:
 evaluator- evaluator to check path permissions.urlMapping- Vaadin servlet url mapping
 
 - 
 - 
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 userroleChecker- a function that can answer if a user has a given role- Returns:
 trueif the user has access to the given path,falseotherwise.
 - 
principalAwareRequestTransformer
public static org.springframework.security.web.access.AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformer principalAwareRequestTransformer(org.springframework.security.web.access.AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformer transformer) Provides a security-aware HTTP request transformer that applies additional processing to the transformed request usingRequestUtil.PrincipalAwareRequestWrapper.A custom
AuthorizationManagerWebInvocationPrivilegeEvaluator.HttpServletRequestTransformerbean handlingHttpServletRequest.getUserPrincipal()method should be exposed by the application whenSpringAccessPathCheckeris used in conjunction with Spring Security request matchers that requires to access that information to preventUnsupportedOperationExceptions.- Parameters:
 transformer- the original HTTP request transformer to be wrapped- Returns:
 - a new HTTP request transformer that wraps the transformed request with enhanced security awareness
 
 
 -