com.vaadin.flow.spring.security.
Class NavigationAccessControlConfigurer
Allows to configure the NavigationAccessControl
.
To configure Flow navigation access control, a Spring bean on type
NavigationAccessControlConfigurer
should be defined.
In Spring Boot applications, a default
NavigationAccessControlConfigurer
bean is provided. It activates
AnnotatedViewAccessChecker
, but it disables the
NavigationAccessControl
, for backward compatibility.
However, if Spring Security is configured extending
VaadinWebSecurity
, the NavigationAccessControl
is enabled
automatically.
Default settings can be overridden by defining a custom
NavigationAccessControlConfigurer
bean.
@Bean
NavigationAccessControlConfigurer navigationAccessControlConfigurer() {
return new NavigationAccessControlConfigurer()
.withRoutePathAccessChecker().withLoginView(LoginView.class);
}
NOTE: if the bean in exposed in a configuration class that extends
VaadinWebSecurity
, the method must be defined static
to
prevent cyclic dependencies errors.
@Bean
class SecurityConfig extends VaadinWebSecurity {
static NavigationAccessControlConfigurer navigationAccessControlConfigurer() {
return new NavigationAccessControlConfigurer()
.withRoutePathAccessChecker().withLoginView(LoginView.class);
}
}
NavigationAccessControl
bean can be configured by:
- activating out-of-the-box navigation access checkers
- providing custom navigation access checkers implementations
- set the login view class or path
- completely disable access control
The
NavigationAccessControl
will automatically be disabled if no
navigation access checkers are provided.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends NavigationAccessControl>
Tbuild
(BiFunction<List<NavigationAccessChecker>, AccessCheckDecisionResolver, T> factory, List<NavigationAccessChecker> availableCheckers) Builds a
NavigationAccessControl
instance, configured according to this configurer instance settings.disabled()
Disables the
NavigationAccessControl
.Enables the
AnnotatedViewAccessChecker
.Adds to
NavigationAccessControl
all the registeredNavigationAccessChecker
beans that matches the given filter.Sets the
AccessCheckDecisionResolver
for the navigation access control.withLoginView
(Class<? extends Component> loginView) Sets the Flow login view to use.
withLoginView
(String loginViewPath) Sets the path of the login view.
withNavigationAccessChecker
(NavigationAccessChecker accessChecker) Adds the given
NavigationAccessChecker
to the collection of checker that will be used byNavigationAccessControl
.withNavigationAccessCheckers
(Collection<NavigationAccessChecker> accessChecker) Adds the given
NavigationAccessChecker
to the collection of checker that will be used byNavigationAccessControl
.Enables the
RoutePathAccessChecker
.
-
Constructor Details
-
NavigationAccessControlConfigurer
public NavigationAccessControlConfigurer()
-
-
Method Details
-
withAnnotatedViewAccessChecker
Enables the
AnnotatedViewAccessChecker
.Returns:
this instance for further customization.
-
withRoutePathAccessChecker
Enables the
RoutePathAccessChecker
.Returns:
this instance for further customization.
-
withDecisionResolver
Sets the
AccessCheckDecisionResolver
for the navigation access control.The
AccessCheckDecisionResolver
is responsible for taking the final decision on target view access grant, based on the response of the navigation access checkers.Parameters:
resolver
- the decision resolver to use for navigation access control.Returns:
this instance for further customization.
-
disabled
Disables the
NavigationAccessControl
.Returns:
this instance for further customization.
-
withLoginView
Sets the Flow login view to use.
Parameters:
loginView
- the Flow view to use as login viewReturns:
this instance for further customization.
-
withLoginView
Sets the path of the login view.
Parameters:
loginViewPath
- the path of the login viewReturns:
this instance for further customization.
-
build
public <T extends NavigationAccessControl> T build(BiFunction<List<NavigationAccessChecker>, AccessCheckDecisionResolver, T> factory, List<NavigationAccessChecker> availableCheckers) Builds a
NavigationAccessControl
instance, configured according to this configurer instance settings.Type Parameters:
T
- the type of theNavigationAccessControl
Parameters:
factory
- a function that build the desired type of navigation access control.availableCheckers
- the list of all available navigation access checkers registered in the system.Returns:
a configured
NavigationAccessControl
instance, never null.
-