|
|
|
@ -94,10 +94,12 @@ public class NamespaceHttpTests { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.accessDecisionManager(ACCESS_DECISION_MANAGER); |
|
|
|
.accessDecisionManager(ACCESS_DECISION_MANAGER); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -114,6 +116,7 @@ public class NamespaceHttpTests { |
|
|
|
static class AccessDeniedPageConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class AccessDeniedPageConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.antMatchers("/admin").hasRole("ADMIN") |
|
|
|
.antMatchers("/admin").hasRole("ADMIN") |
|
|
|
@ -121,6 +124,7 @@ public class NamespaceHttpTests { |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.exceptionHandling() |
|
|
|
.exceptionHandling() |
|
|
|
.accessDeniedPage("/AccessDeniedPage"); |
|
|
|
.accessDeniedPage("/AccessDeniedPage"); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -145,11 +149,13 @@ public class NamespaceHttpTests { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().authenticated() |
|
|
|
.anyRequest().authenticated() |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.formLogin(); |
|
|
|
.formLogin(); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -168,12 +174,14 @@ public class NamespaceHttpTests { |
|
|
|
static class CreateSessionAlwaysConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class CreateSessionAlwaysConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.sessionManagement() |
|
|
|
.sessionManagement() |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS); |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -191,12 +199,14 @@ public class NamespaceHttpTests { |
|
|
|
static class CreateSessionStatelessConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class CreateSessionStatelessConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.sessionManagement() |
|
|
|
.sessionManagement() |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.STATELESS); |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.STATELESS); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -220,6 +230,7 @@ public class NamespaceHttpTests { |
|
|
|
static class IfRequiredConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class IfRequiredConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.antMatchers("/unsecure").permitAll() |
|
|
|
.antMatchers("/unsecure").permitAll() |
|
|
|
@ -229,6 +240,7 @@ public class NamespaceHttpTests { |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.formLogin(); |
|
|
|
.formLogin(); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -246,12 +258,14 @@ public class NamespaceHttpTests { |
|
|
|
static class CreateSessionNeverConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class CreateSessionNeverConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().anonymous() |
|
|
|
.anyRequest().anonymous() |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.sessionManagement() |
|
|
|
.sessionManagement() |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.NEVER); |
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.NEVER); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -268,6 +282,7 @@ public class NamespaceHttpTests { |
|
|
|
static class EntryPointRefConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class EntryPointRefConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().authenticated() |
|
|
|
.anyRequest().authenticated() |
|
|
|
@ -276,6 +291,7 @@ public class NamespaceHttpTests { |
|
|
|
.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/entry-point")) |
|
|
|
.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/entry-point")) |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.formLogin(); |
|
|
|
.formLogin(); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -299,8 +315,10 @@ public class NamespaceHttpTests { |
|
|
|
static class JaasApiProvisionConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class JaasApiProvisionConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.addFilter(new JaasApiIntegrationFilter()); |
|
|
|
.addFilter(new JaasApiIntegrationFilter()); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -317,12 +335,14 @@ public class NamespaceHttpTests { |
|
|
|
static class RealmConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class RealmConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().authenticated() |
|
|
|
.anyRequest().authenticated() |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.httpBasic() |
|
|
|
.httpBasic() |
|
|
|
.realmName("RealmConfig"); |
|
|
|
.realmName("RealmConfig"); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -341,8 +361,10 @@ public class NamespaceHttpTests { |
|
|
|
static class RequestMatcherAntConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class RequestMatcherAntConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.antMatcher("/api/**"); |
|
|
|
.antMatcher("/api/**"); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -361,8 +383,10 @@ public class NamespaceHttpTests { |
|
|
|
static class RequestMatcherRegexConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class RequestMatcherRegexConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.regexMatcher("/regex/.*"); |
|
|
|
.regexMatcher("/regex/.*"); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -381,8 +405,10 @@ public class NamespaceHttpTests { |
|
|
|
static class RequestMatcherRefConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class RequestMatcherRefConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
protected void configure(HttpSecurity http) { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.requestMatcher(new MyRequestMatcher()); |
|
|
|
.requestMatcher(new MyRequestMatcher()); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static class MyRequestMatcher implements RequestMatcher { |
|
|
|
static class MyRequestMatcher implements RequestMatcher { |
|
|
|
@ -439,6 +465,7 @@ public class NamespaceHttpTests { |
|
|
|
static class SecurityContextRepoConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class SecurityContextRepoConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().authenticated() |
|
|
|
.anyRequest().authenticated() |
|
|
|
@ -447,6 +474,7 @@ public class NamespaceHttpTests { |
|
|
|
.securityContextRepository(new NullSecurityContextRepository()) |
|
|
|
.securityContextRepository(new NullSecurityContextRepository()) |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.formLogin(); |
|
|
|
.formLogin(); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -470,12 +498,14 @@ public class NamespaceHttpTests { |
|
|
|
static class ServletApiProvisionConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class ServletApiProvisionConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.anyRequest().permitAll() |
|
|
|
.and() |
|
|
|
.and() |
|
|
|
.servletApi() |
|
|
|
.servletApi() |
|
|
|
.disable(); |
|
|
|
.disable(); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -492,9 +522,11 @@ public class NamespaceHttpTests { |
|
|
|
static class ServletApiProvisionDefaultsConfig extends WebSecurityConfigurerAdapter { |
|
|
|
static class ServletApiProvisionDefaultsConfig extends WebSecurityConfigurerAdapter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.anyRequest().permitAll(); |
|
|
|
.anyRequest().permitAll(); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -525,11 +557,13 @@ public class NamespaceHttpTests { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.authorizeRequests() |
|
|
|
.authorizeRequests() |
|
|
|
.antMatchers("/users**", "/sessions/**").hasRole("USER") |
|
|
|
.antMatchers("/users**", "/sessions/**").hasRole("USER") |
|
|
|
.antMatchers("/signup").permitAll() |
|
|
|
.antMatchers("/signup").permitAll() |
|
|
|
.anyRequest().hasRole("USER"); |
|
|
|
.anyRequest().hasRole("USER"); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -560,11 +594,13 @@ public class NamespaceHttpTests { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
http |
|
|
|
http |
|
|
|
.apply(new UrlAuthorizationConfigurer<>(getApplicationContext())).getRegistry() |
|
|
|
.apply(new UrlAuthorizationConfigurer<>(getApplicationContext())).getRegistry() |
|
|
|
.antMatchers("/users**", "/sessions/**").hasRole("USER") |
|
|
|
.antMatchers("/users**", "/sessions/**").hasRole("USER") |
|
|
|
.antMatchers("/signup").hasRole("ANONYMOUS") |
|
|
|
.antMatchers("/signup").hasRole("ANONYMOUS") |
|
|
|
.anyRequest().hasRole("USER"); |
|
|
|
.anyRequest().hasRole("USER"); |
|
|
|
|
|
|
|
// @formatter:on
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|