Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit 96882e0

Browse files
author
Mario
committed
1123 - Added changes based on 1st round of review
1 parent a9f1d5c commit 96882e0

File tree

3 files changed

+27
-35
lines changed

3 files changed

+27
-35
lines changed

extensions/spring/stormpath-spring-security-webmvc/src/main/java/com/stormpath/spring/config/StormpathSecurityConfigurerAdapter.java

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public class StormpathSecurityConfigurerAdapter extends AbstractStormpathSecurit
6969
@Autowired
7070
AccountResolverFilter springSecurityResolvedAccountFilter;
7171

72-
//Based on this http://docs.spring.io/spring-security/site/docs/4.1.2.RELEASE/reference/htmlsingle/#filter-ordering
73-
//We are introducing a new filter in order to place the Stormpath Account in context
72+
//Based on http://docs.spring.io/spring-security/site/docs/4.2.0.RELEASE/reference/htmlsingle/#filter-ordering
73+
//we are introducing a new filter in order to place the Stormpath Account in context.
7474
//This is required when a user is logged in (cookie in browser) and then the Web App is restarted. In that case
7575
//Spring security will deny access at some point and redirect you to login. Stormpath will see your cookie, will do an
7676
//automatic login and will forward you to the original URL but Spring Security will not have its security context set
@@ -188,10 +188,8 @@ public class StormpathSecurityConfigurerAdapter extends AbstractStormpathSecurit
188188
/**
189189
* The pre-defined Stormpath access control settings are defined here.
190190
*
191-
* @param http
192-
* the {@link HttpSecurity} to be modified
193-
* @throws Exception
194-
* if an error occurs
191+
* @param http the {@link HttpSecurity} to be modified
192+
* @throws Exception if an error occurs
195193
*/
196194
@Override
197195
public void init(HttpSecurity http) throws Exception {
@@ -225,38 +223,34 @@ public void init(HttpSecurity http) throws Exception {
225223
if (idSiteEnabled && loginEnabled) {
226224
String permittedResultPath = (idSiteEnabled) ? idSiteResultUri : samlResultUri;
227225

228-
http
229-
.authorizeRequests()
230-
.antMatchers(loginUri).permitAll()
231-
.antMatchers(permittedResultPath).permitAll()
232-
.and().exceptionHandling().authenticationEntryPoint(stormpathAuthenticationEntryPoint); //Fix for https://github.com/stormpath/stormpath-sdk-java/issues/714
226+
http.authorizeRequests()
227+
.antMatchers(loginUri).permitAll()
228+
.antMatchers(permittedResultPath).permitAll()
229+
.and().exceptionHandling().authenticationEntryPoint(stormpathAuthenticationEntryPoint); //Fix for https://github.com/stormpath/stormpath-sdk-java/issues/714
233230
} else if (stormpathWebEnabled) {
234231
if (loginEnabled) {
235232
// make sure that /login and /login?status=... is permitted
236233
String loginUriMatch = (loginUri.endsWith("*")) ? loginUri : loginUri + "*";
237234

238-
http
239-
.authorizeRequests()
240-
.antMatchers(loginUriMatch).permitAll()
241-
.antMatchers(googleCallbackUri).permitAll()
242-
.antMatchers(githubCallbackUri).permitAll()
243-
.antMatchers(facebookCallbackUri).permitAll()
244-
.antMatchers(linkedinCallbackUri).permitAll()
245-
.and().exceptionHandling().authenticationEntryPoint(stormpathAuthenticationEntryPoint); //Fix for https://github.com/stormpath/stormpath-sdk-java/issues/714
235+
http.authorizeRequests()
236+
.antMatchers(loginUriMatch).permitAll()
237+
.antMatchers(googleCallbackUri).permitAll()
238+
.antMatchers(githubCallbackUri).permitAll()
239+
.antMatchers(facebookCallbackUri).permitAll()
240+
.antMatchers(linkedinCallbackUri).permitAll()
241+
.and().exceptionHandling().authenticationEntryPoint(stormpathAuthenticationEntryPoint); //Fix for https://github.com/stormpath/stormpath-sdk-java/issues/714
246242
}
247243

248244
if (meEnabled) {
249-
http
250-
.authorizeRequests().antMatchers(meUri).fullyAuthenticated();
245+
http.authorizeRequests().antMatchers(meUri).fullyAuthenticated();
251246
}
252247

253248
http.authorizeRequests()
254-
.antMatchers("/assets/css/stormpath.css").permitAll()
255-
.antMatchers("/assets/css/custom.stormpath.css").permitAll()
256-
.antMatchers("/assets/js/stormpath.js").permitAll()
257-
// fix for https://github.com/stormpath/stormpath-sdk-java/issues/822
258-
.antMatchers("/WEB-INF/jsp/stormpath/**").permitAll();
259-
249+
.antMatchers("/assets/css/stormpath.css").permitAll()
250+
.antMatchers("/assets/css/custom.stormpath.css").permitAll()
251+
.antMatchers("/assets/js/stormpath.js").permitAll()
252+
// fix for https://github.com/stormpath/stormpath-sdk-java/issues/822
253+
.antMatchers("/WEB-INF/jsp/stormpath/**").permitAll();
260254
}
261255

262256
if (idSiteEnabled || callbackEnabled || stormpathWebEnabled) {
@@ -270,10 +264,8 @@ public void init(HttpSecurity http) throws Exception {
270264
httpSecurityLogoutConfigurer.logoutSuccessUrl(logoutNextUri);
271265
}
272266

273-
httpSecurityLogoutConfigurer
274-
.addLogoutHandler(logoutHandler)
275-
.and().authorizeRequests()
276-
.antMatchers(logoutUri).permitAll();
267+
httpSecurityLogoutConfigurer.addLogoutHandler(logoutHandler)
268+
.and().authorizeRequests().antMatchers(logoutUri).permitAll();
277269
}
278270

279271
if (forgotEnabled) {

extensions/spring/stormpath-spring-security-webmvc/src/test/groovy/com/stormpath/spring/config/DisabledStormpathSpringSecurityWebMvcConfigurationIT.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ class DisabledStormpathSpringSecurityWebMvcConfigurationIT extends AbstractClien
7171
super.setUp()
7272

7373
mvc = MockMvcBuilders.webAppContextSetup(context)
74-
.addFilter(springSecurityFilterChain, "/*") //Spring security in front of Stormpath
75-
.addFilter(stormpathFilter, "/*")
76-
.build();
74+
.addFilter(springSecurityFilterChain, "/*") //Spring security in front of Stormpath
75+
.addFilter(stormpathFilter, "/*")
76+
.build();
7777
}
7878

7979
@Test

extensions/spring/stormpath-spring-security-webmvc/src/test/groovy/com/stormpath/spring/config/DisabledStormpathSpringSecurityWebMvcTestAppConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static com.stormpath.spring.config.StormpathWebSecurityConfigurer.stormpath;
2424

2525
/**
26-
* @since 1.0.RC5
26+
* @since 1.3.0
2727
*/
2828
@Configuration
2929
@EnableStormpathWebSecurity

0 commit comments

Comments
 (0)