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

Commit 77fe4b4

Browse files
authored
Merge pull request #1250 from stormpath/issue/1238
Ensure that a default WebSecurityConfigurerAdapter is loaded if one is not specified
2 parents dcfa056 + 4cee57d commit 77fe4b4

File tree

7 files changed

+25
-72
lines changed

7 files changed

+25
-72
lines changed

docs/source/tutorial.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ disable it. That's where the ``application.properties`` files comes in:
239239
.. code-block:: java
240240
:linenos:
241241
242-
security.basic.enabled = false
242+
stormpath.spring.security.enabled = false
243243
244244
That property disables Spring Security and avoids our Spring Security integration to be loaded.
245245

@@ -899,6 +899,14 @@ As you can see from the examples above, Stormpath provides powerful oauth2 Token
899899
``/oauth/token`` endpoint. There is no additional coding required on your part to make use of the Token Management
900900
feature.
901901

902+
#if( $springboot )
903+
You may notice that there is no class in this part of the tutorial that extends ``WebSecurityConfigurerAdapter``.
904+
In this particular case, *all* user-defined paths are locked down. This is the default for Spring Security and the
905+
Stormpath Spring Security integration follows suit.
906+
907+
If you fire up the tutorial app and browse to the home page: http://localhost:8080/, you will be redirected to `/login`.
908+
#end
909+
902910
.. _wrapping-up:
903911

904912
Wrapping Up

examples/spring-security-spring-boot-webmvc-bare-bones/src/main/java/com/stormpath/spring/boot/examples/SpringSecurityWebAppConfig.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

extensions/spring/boot/stormpath-spring-security-webmvc-spring-boot-starter/src/main/java/com/stormpath/spring/boot/autoconfigure/StormpathWebSecurityAutoConfiguration.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
3434
import org.springframework.context.annotation.Bean;
3535
import org.springframework.context.annotation.Configuration;
36+
import org.springframework.core.annotation.Order;
3637
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
38+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
39+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
3740
import org.springframework.security.web.AuthenticationEntryPoint;
3841
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
3942
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
@@ -45,6 +48,8 @@
4548
import javax.servlet.Filter;
4649
import javax.servlet.Servlet;
4750

51+
import static org.springframework.boot.autoconfigure.security.SecurityProperties.ACCESS_OVERRIDE_ORDER;
52+
4853
/**
4954
* @since 1.0.RC5
5055
*/
@@ -179,4 +184,12 @@ public StormpathWrapperFilter stormpathWrapperFilter() {
179184
return super.stormpathWrapperFilter();
180185
}
181186

187+
// Fix for: https://github.com/stormpath/stormpath-sdk-java/issues/1238
188+
// If stormpath is enabled, we don't want the spring security default definition
189+
@Order(ACCESS_OVERRIDE_ORDER)
190+
@Configuration
191+
protected static class SpringSecurityWebAppConfig extends WebSecurityConfigurerAdapter {
192+
@Override
193+
protected void configure(HttpSecurity http) throws Exception {}
194+
}
182195
}

tutorials/spring-boot/00-the-basics/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
#
2020
#stormpath.application.href = https://api.stormpath.com/v1/applications/YOUR_APPLICATION_ID_HERE
2121

22-
security.basic.enabled = false
22+
stormpath.spring.security.enabled = false

tutorials/spring-boot/01-some-access-controls/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
#
2020
#stormpath.application.href = https://api.stormpath.com/v1/applications/YOUR_APPLICATION_ID_HERE
2121

22-
security.basic.enabled = false
22+
stormpath.spring.security.enabled = false

tutorials/spring-boot/05-token-management/src/main/java/com/stormpath/tutorial/config/SpringSecurityWebAppConfig.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

tutorials/spring/00-the-basics/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
#
2020
#stormpath.application.href = https://api.stormpath.com/v1/applications/YOUR_APPLICATION_ID_HERE
2121

22-
security.basic.enabled = false
22+
stormpath.spring.security.enabled = false

0 commit comments

Comments
 (0)