|
@@ -4,8 +4,9 @@ import com.ningdatech.basic.util.NdJsonUtil; |
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
import com.ningdatech.pmapi.common.constant.CommonConst; |
|
|
import com.ningdatech.pmapi.common.constant.CommonConst; |
|
|
import com.ningdatech.pmapi.user.security.auth.handler.DefaultExpiredSessionStrategy; |
|
|
|
|
|
|
|
|
import com.ningdatech.pmapi.user.security.auth.agent.AgentAuthSecurityConfig; |
|
|
import com.ningdatech.pmapi.user.security.auth.credential.CredentialAuthSecurityConfig; |
|
|
import com.ningdatech.pmapi.user.security.auth.credential.CredentialAuthSecurityConfig; |
|
|
|
|
|
import com.ningdatech.pmapi.user.security.auth.handler.DefaultExpiredSessionStrategy; |
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
import org.springframework.http.HttpStatus; |
|
|
import org.springframework.http.HttpStatus; |
|
@@ -31,13 +32,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
private final CredentialAuthSecurityConfig credentialAuthSecurityConfig; |
|
|
private final CredentialAuthSecurityConfig credentialAuthSecurityConfig; |
|
|
private final LogoutSuccessHandler logoutSuccessHandler; |
|
|
private final LogoutSuccessHandler logoutSuccessHandler; |
|
|
private final DefaultExpiredSessionStrategy defaultExpiredSessionStrategy; |
|
|
private final DefaultExpiredSessionStrategy defaultExpiredSessionStrategy; |
|
|
|
|
|
private final AgentAuthSecurityConfig agentAuthSecurityConfig; |
|
|
|
|
|
|
|
|
public WebSecurityConfig(AuthProperties authProperties, |
|
|
public WebSecurityConfig(AuthProperties authProperties, |
|
|
CredentialAuthSecurityConfig credentialAuthSecurityConfig, |
|
|
CredentialAuthSecurityConfig credentialAuthSecurityConfig, |
|
|
|
|
|
AgentAuthSecurityConfig agentAuthSecurityConfig, |
|
|
@Qualifier(value = "defaultLogoutSuccessHandler") LogoutSuccessHandler logoutSuccessHandler, |
|
|
@Qualifier(value = "defaultLogoutSuccessHandler") LogoutSuccessHandler logoutSuccessHandler, |
|
|
DefaultExpiredSessionStrategy defaultExpiredSessionStrategy) { |
|
|
DefaultExpiredSessionStrategy defaultExpiredSessionStrategy) { |
|
|
this.authProperties = authProperties; |
|
|
this.authProperties = authProperties; |
|
|
this.credentialAuthSecurityConfig = credentialAuthSecurityConfig; |
|
|
this.credentialAuthSecurityConfig = credentialAuthSecurityConfig; |
|
|
|
|
|
this.agentAuthSecurityConfig = agentAuthSecurityConfig; |
|
|
this.logoutSuccessHandler = logoutSuccessHandler; |
|
|
this.logoutSuccessHandler = logoutSuccessHandler; |
|
|
this.defaultExpiredSessionStrategy = defaultExpiredSessionStrategy; |
|
|
this.defaultExpiredSessionStrategy = defaultExpiredSessionStrategy; |
|
|
} |
|
|
} |
|
@@ -47,7 +51,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
assemblerPreAuthUrls(http); |
|
|
assemblerPreAuthUrls(http); |
|
|
http.formLogin() |
|
|
http.formLogin() |
|
|
.loginPage(authProperties.getAuthRequireUrl()) |
|
|
.loginPage(authProperties.getAuthRequireUrl()) |
|
|
.and().apply(credentialAuthSecurityConfig) |
|
|
|
|
|
|
|
|
.and().apply(credentialAuthSecurityConfig).and().apply(agentAuthSecurityConfig) |
|
|
.and() |
|
|
.and() |
|
|
.authorizeRequests().antMatchers(authProperties.getIgnoreAuthUrlsArray()).permitAll().anyRequest() |
|
|
.authorizeRequests().antMatchers(authProperties.getIgnoreAuthUrlsArray()).permitAll().anyRequest() |
|
|
.authenticated().and() |
|
|
.authenticated().and() |
|
|