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

Commit a9f1d5c

Browse files
author
Mario
committed
1123 - marked stormpathSecurityConfigurerAdapter as not required
1 parent 9fc5220 commit a9f1d5c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import org.slf4j.LoggerFactory;
2020
import org.springframework.beans.factory.annotation.Autowired;
2121
import org.springframework.beans.factory.annotation.Qualifier;
22+
import org.springframework.beans.factory.annotation.Value;
2223
import org.springframework.context.ApplicationContext;
24+
import org.springframework.context.annotation.Conditional;
2325
import org.springframework.context.annotation.Configuration;
2426
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
2527
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -33,10 +35,13 @@ public class StormpathWebSecurityConfigurer extends AbstractHttpConfigurer<Storm
3335

3436
private static final Logger log = LoggerFactory.getLogger(StormpathWebSecurityConfigurer.class);
3537

36-
@Autowired
38+
@Autowired(required = false) //when stormpath.enabled = false then this bean is not present but Spring Boot is still loading this class, so we need required = false here
3739
@Qualifier("stormpathSecurityConfigurerAdapter")
3840
protected SecurityConfigurerAdapter stormpathSecurityConfigurerAdapter;
3941

42+
@Value("#{ @environment['stormpath.enabled'] ?: true }")
43+
protected boolean stormpathEnabled;
44+
4045
/**
4146
* Extend WebSecurityConfigurerAdapter and configure the {@code HttpSecurity} object using
4247
* the {@link com.stormpath.spring.config.StormpathWebSecurityConfigurer#stormpath stormpath()} utility method.
@@ -77,7 +82,9 @@ public void init(HttpSecurity http) throws Exception {
7782
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
7883
context.getAutowireCapableBeanFactory().autowireBean(this);
7984

80-
stormpathSecurityConfigurerAdapter.init(http);
85+
if (stormpathEnabled) {
86+
stormpathSecurityConfigurerAdapter.init(http);
87+
}
8188
}
8289

8390
}

0 commit comments

Comments
 (0)