Package com.vaadin.flow.spring.security
Class SpringNavigationAccessControl
java.lang.Object
com.vaadin.flow.server.auth.NavigationAccessControl
com.vaadin.flow.spring.security.SpringNavigationAccessControl
- All Implemented Interfaces:
BeforeEnterListener
,BeforeEnterHandler
,Serializable
A Spring specific navigation access control that falls back to Spring
mechanisms for user retrieval and role checking, when the generic mechanisms
do not work.
In Spring Boot application, a
SpringNavigationAccessControl
is
provided by default, but its behavior can be configured by defining a
NavigationAccessControlConfigurer
bean.-
Field Summary
Fields inherited from class com.vaadin.flow.server.auth.NavigationAccessControl
SESSION_STORED_REDIRECT, SESSION_STORED_REDIRECT_ABSOLUTE
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance with the default view annotation checker and decision resolver.SpringNavigationAccessControl
(Collection<NavigationAccessChecker> checkerList, AccessCheckDecisionResolver decisionResolver) Create a new instance with given checkers and decision resolver. -
Method Summary
Modifier and TypeMethodDescriptionprotected Principal
getPrincipal
(VaadinRequest request) Gets the principal for the currently logged in user.getRolesChecker
(VaadinRequest request) Gets a function for checking roles for the currently logged in user.Methods inherited from class com.vaadin.flow.server.auth.NavigationAccessControl
beforeEnter, checkAccess, createNavigationContext, getAccessDeniedException, getLoginUrl, getLoginView, getRequestURL, hasAccessChecker, isEnabled, setEnabled, setLoginView, setLoginView
-
Constructor Details
-
SpringNavigationAccessControl
public SpringNavigationAccessControl()Create a new instance with the default view annotation checker and decision resolver. -
SpringNavigationAccessControl
public SpringNavigationAccessControl(Collection<NavigationAccessChecker> checkerList, AccessCheckDecisionResolver decisionResolver) Create a new instance with given checkers and decision resolver.- Parameters:
checkerList
- collection of navigation access checker.decisionResolver
- the decision resolver.
-
-
Method Details
-
getPrincipal
Description copied from class:NavigationAccessControl
Gets the principal for the currently logged in user.- Overrides:
getPrincipal
in classNavigationAccessControl
- Parameters:
request
- the current request ornull
if no request is in progress (e.g. in a background thread)- Returns:
- a representation of the currently logged in user or
null
if no user is currently logged in
-
getRolesChecker
Description copied from class:NavigationAccessControl
Gets a function for checking roles for the currently logged in user.- Overrides:
getRolesChecker
in classNavigationAccessControl
- Parameters:
request
- the current request ornull
if no request is in progress (e.g. in a background thread)- Returns:
- a function which takes a role name and returns
true
if the user is included in that role
-