Package com.vaadin.flow.spring.security
Class VaadinWebSecurityConfigurerAdapter
- java.lang.Object
-
- org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
-
- com.vaadin.flow.spring.security.VaadinWebSecurityConfigurerAdapter
-
- All Implemented Interfaces:
org.springframework.security.config.annotation.SecurityConfigurer<javax.servlet.Filter,org.springframework.security.config.annotation.web.builders.WebSecurity>,org.springframework.security.config.annotation.web.WebSecurityConfigurer<org.springframework.security.config.annotation.web.builders.WebSecurity>
@Deprecated public abstract class VaadinWebSecurityConfigurerAdapter extends org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
Deprecated.Use component-based security configurationVaadinWebSecurityProvides basic Vaadin security configuration for the project.Sets up security rules for a Vaadin application and restricts all URLs except for public resources and internal Vaadin URLs to authenticated user.
The default behavior can be altered by extending the public/protected methods in the class.
To use this, create your own web security configurer adapter class by extending this class instead of
WebSecurityConfigurerAdapterand annotate it with@EnableWebSecurityand@Configuration.For example:
@EnableWebSecurity @Configuration public class MySecurityConfigurerAdapter extends VaadinWebSecurityConfigurerAdapter { }
-
-
Constructor Summary
Constructors Constructor Description VaadinWebSecurityConfigurerAdapter()Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected StringapplyUrlMapping(String path)Deprecated.Helper method to prepend configured servlet path to the given path.protected voidconfigure(org.springframework.security.config.annotation.web.builders.HttpSecurity http)Deprecated.voidconfigure(org.springframework.security.config.annotation.web.builders.WebSecurity web)Deprecated.The paths listed as "ignoring" in this method are handled without any Spring Security involvement.static org.springframework.security.web.util.matcher.RequestMatchergetDefaultHttpSecurityPermitMatcher()Deprecated.Matcher for framework internal requests.static org.springframework.security.web.util.matcher.RequestMatchergetDefaultHttpSecurityPermitMatcher(String urlMapping)Deprecated.Matcher for framework internal requests, with Vaadin servlet mapped on the given path.static org.springframework.security.web.util.matcher.RequestMatchergetDefaultWebSecurityIgnoreMatcher()Deprecated.Matcher for Vaadin static (public) resources.static org.springframework.security.web.util.matcher.RequestMatchergetDefaultWebSecurityIgnoreMatcher(String urlMapping)Deprecated.Matcher for Vaadin static (public) resources, with Vaadin servlet mapped on the given path.protected voidsetLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, Class<? extends Component> flowLoginView)Deprecated.Sets up login for the application using the given Flow login view.protected voidsetLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, Class<? extends Component> flowLoginView, String logoutSuccessUrl)Deprecated.Sets up login for the application using the given Flow login view.protected voidsetLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, String hillaLoginViewPath)Deprecated.Sets up login for the application using form login with the given path for the login view.protected voidsetLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, String hillaLoginViewPath, String logoutSuccessUrl)Deprecated.Sets up login for the application using form login with the given path for the login view.protected voidsetStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http, SecretKey secretKey, String issuer)Deprecated.Sets up stateless JWT authentication using cookies.protected voidsetStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http, SecretKey secretKey, String issuer, long expiresIn)Deprecated.Sets up stateless JWT authentication using cookies.-
Methods inherited from class org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
authenticationManager, authenticationManagerBean, configure, getApplicationContext, getHttp, init, setApplicationContext, setAuthenticationConfiguration, setContentNegotationStrategy, setObjectPostProcessor, setTrustResolver, userDetailsService, userDetailsServiceBean
-
-
-
-
Method Detail
-
configure
public void configure(org.springframework.security.config.annotation.web.builders.WebSecurity web) throws ExceptionDeprecated.The paths listed as "ignoring" in this method are handled without any Spring Security involvement. They have no access to any security context etc.- Specified by:
configurein interfaceorg.springframework.security.config.annotation.SecurityConfigurer<javax.servlet.Filter,org.springframework.security.config.annotation.web.builders.WebSecurity>- Overrides:
configurein classorg.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter- Throws:
Exception
-
configure
protected void configure(org.springframework.security.config.annotation.web.builders.HttpSecurity http) throws ExceptionDeprecated.- Overrides:
configurein classorg.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter- Throws:
Exception
-
getDefaultHttpSecurityPermitMatcher
public static org.springframework.security.web.util.matcher.RequestMatcher getDefaultHttpSecurityPermitMatcher()
Deprecated.Matcher for framework internal requests. Assumes Vaadin servlet to be mapped on root path (/*).- Returns:
- default
HttpSecuritybypass matcher
-
getDefaultHttpSecurityPermitMatcher
public static org.springframework.security.web.util.matcher.RequestMatcher getDefaultHttpSecurityPermitMatcher(String urlMapping)
Deprecated.Matcher for framework internal requests, with Vaadin servlet mapped on the given path.- Parameters:
urlMapping- url mapping for the Vaadin servlet.- Returns:
- default
HttpSecuritybypass matcher
-
getDefaultWebSecurityIgnoreMatcher
public static org.springframework.security.web.util.matcher.RequestMatcher getDefaultWebSecurityIgnoreMatcher()
Deprecated.Matcher for Vaadin static (public) resources. Assumes Vaadin servlet to be mapped on root path (/*).- Returns:
- default
WebSecurityignore matcher
-
getDefaultWebSecurityIgnoreMatcher
public static org.springframework.security.web.util.matcher.RequestMatcher getDefaultWebSecurityIgnoreMatcher(String urlMapping)
Deprecated.Matcher for Vaadin static (public) resources, with Vaadin servlet mapped on the given path. Assumes Vaadin servlet to be mapped on root path (/*).- Parameters:
urlMapping- the url mapping for the Vaadin servlet- Returns:
- default
WebSecurityignore matcher
-
setLoginView
protected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, String hillaLoginViewPath) throws ExceptionDeprecated.Sets up login for the application using form login with the given path for the login view.This is used when your application uses a Hilla based login view available at the given path.
- Parameters:
http- the http security fromconfigure(HttpSecurity)hillaLoginViewPath- the path to the login view- Throws:
Exception- if something goes wrong
-
setLoginView
protected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, String hillaLoginViewPath, String logoutSuccessUrl) throws ExceptionDeprecated.Sets up login for the application using form login with the given path for the login view.This is used when your application uses a Hilla based login view available at the given path.
- Parameters:
http- the http security fromconfigure(HttpSecurity)hillaLoginViewPath- the path to the login viewlogoutSuccessUrl- the URL to redirect the user to after logging out- Throws:
Exception- if something goes wrong
-
setLoginView
protected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, Class<? extends Component> flowLoginView) throws ExceptionDeprecated.Sets up login for the application using the given Flow login view.- Parameters:
http- the http security fromconfigure(HttpSecurity)flowLoginView- the login view to use- Throws:
Exception- if something goes wrong
-
setLoginView
protected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http, Class<? extends Component> flowLoginView, String logoutSuccessUrl) throws ExceptionDeprecated.Sets up login for the application using the given Flow login view.- Parameters:
http- the http security fromconfigure(HttpSecurity)flowLoginView- the login view to uselogoutSuccessUrl- the URL to redirect the user to after logging out- Throws:
Exception- if something goes wrong
-
setStatelessAuthentication
protected void setStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http, SecretKey secretKey, String issuer) throws ExceptionDeprecated.Sets up stateless JWT authentication using cookies.- Parameters:
http- the http security fromconfigure(HttpSecurity)secretKey- the secret key for encoding and decoding JWTs, must use aMacAlgorithmalgorithm nameissuer- the issuer JWT claim- Throws:
Exception- if something goes wrong
-
setStatelessAuthentication
protected void setStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http, SecretKey secretKey, String issuer, long expiresIn) throws ExceptionDeprecated.Sets up stateless JWT authentication using cookies.- Parameters:
http- the http security fromconfigure(HttpSecurity)secretKey- the secret key for encoding and decoding JWTs, must use aMacAlgorithmalgorithm nameissuer- the issuer JWT claimexpiresIn- lifetime of the JWT and cookies, in seconds- Throws:
Exception- if something goes wrong
-
applyUrlMapping
protected String applyUrlMapping(String path)
Deprecated.Helper method to prepend configured servlet path to the given path. Path will always be considered as relative to servlet path, even if it starts with a slash character.- Parameters:
path- path to be prefixed with servlet path- Returns:
- the input path prepended by servlet path.
-
-