public abstract class VaadinWebSecurityConfigurerAdapter
extends org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
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 WebSecurityConfigurerAdapter and
annotate it with @EnableWebSecurity and
@Configuration.
For example
@EnableWebSecurity
@Configuration
public class MySecurityConfigurerAdapter extends VaadinWebSecurityConfigurerAdapter {
}
| Constructor and Description |
|---|
VaadinWebSecurityConfigurerAdapter() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configure(org.springframework.security.config.annotation.web.builders.HttpSecurity http) |
void |
configure(org.springframework.security.config.annotation.web.builders.WebSecurity web)
The paths listed as "ignoring" in this method are handled without any
Spring Security involvement.
|
static org.springframework.security.web.util.matcher.RequestMatcher |
getDefaultHttpSecurityPermitMatcher()
Matcher for framework internal requests.
|
static org.springframework.security.web.util.matcher.RequestMatcher |
getDefaultWebSecurityIgnoreMatcher()
Matcher for Vaadin static (public) resources.
|
protected void |
setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
Class<? extends com.vaadin.flow.component.Component> flowLoginView)
Sets up login for the application using the given Flow login view.
|
protected void |
setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
Class<? extends com.vaadin.flow.component.Component> flowLoginView,
String logoutUrl)
Sets up login for the application using the given Flow login view.
|
protected void |
setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
String fusionLoginViewPath)
Sets up login for the application using form login with the given path
for the login view.
|
protected void |
setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
String fusionLoginViewPath,
String logoutUrl)
Sets up login for the application using form login with the given path
for the login view.
|
protected void |
setStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
SecretKey secretKey,
String issuer)
Sets up stateless JWT authentication using cookies.
|
protected void |
setStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
SecretKey secretKey,
String issuer,
long expiresIn)
Sets up stateless JWT authentication using cookies.
|
authenticationManager, authenticationManagerBean, configure, getApplicationContext, getHttp, init, setApplicationContext, setAuthenticationConfiguration, setContentNegotationStrategy, setObjectPostProcessor, setTrustResolver, userDetailsService, userDetailsServiceBeanpublic void configure(org.springframework.security.config.annotation.web.builders.WebSecurity web)
throws Exception
configure in interface org.springframework.security.config.annotation.SecurityConfigurer<javax.servlet.Filter,org.springframework.security.config.annotation.web.builders.WebSecurity>configure in class org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapterExceptionprotected void configure(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
throws Exception
configure in class org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapterExceptionpublic static org.springframework.security.web.util.matcher.RequestMatcher getDefaultHttpSecurityPermitMatcher()
HttpSecurity bypass matcherpublic static org.springframework.security.web.util.matcher.RequestMatcher getDefaultWebSecurityIgnoreMatcher()
WebSecurity ignore matcherprotected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
String fusionLoginViewPath)
throws Exception
This is used when your application uses a Fusion based login view available at the given path.
http - the http security from configure(HttpSecurity)fusionLoginViewPath - the path to the login viewException - if something goes wrongprotected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
String fusionLoginViewPath,
String logoutUrl)
throws Exception
This is used when your application uses a Fusion based login view available at the given path.
http - the http security from configure(HttpSecurity)fusionLoginViewPath - the path to the login viewlogoutUrl - the URL to redirect the user to after logging outException - if something goes wrongprotected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
Class<? extends com.vaadin.flow.component.Component> flowLoginView)
throws Exception
http - the http security from configure(HttpSecurity)flowLoginView - the login view to useException - if something goes wrongprotected void setLoginView(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
Class<? extends com.vaadin.flow.component.Component> flowLoginView,
String logoutUrl)
throws Exception
http - the http security from configure(HttpSecurity)flowLoginView - the login view to uselogoutUrl - the URL to redirect the user to after logging outException - if something goes wrongprotected void setStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
SecretKey secretKey,
String issuer)
throws Exception
http - the http security from configure(HttpSecurity)secretKey - the secret key for encoding and decoding JWTs, must use a
MacAlgorithm algorithm nameissuer - the issuer JWT claimException - if something goes wrongprotected void setStatelessAuthentication(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
SecretKey secretKey,
String issuer,
long expiresIn)
throws Exception
http - the http security from configure(HttpSecurity)secretKey - the secret key for encoding and decoding JWTs, must use a
MacAlgorithm algorithm nameissuer - the issuer JWT claimexpiresIn - lifetime of the JWT and cookies, in secondsException - if something goes wrongCopyright © 2021 Vaadin Ltd. All Rights Reserved.