|
|
@ -1,29 +1,22 @@ |
|
|
package com.mdp; |
|
|
package com.mdp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.mdp.safe.client.jwt.JwtAuthenticationConverter; |
|
|
import com.mdp.safe.client.jwt.JwtAuthenticationConverter; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
|
|
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|
|
import org.springframework.security.config.http.SessionCreationPolicy; |
|
|
|
|
|
import org.springframework.security.oauth2.jwt.JwtDecoder; |
|
|
import org.springframework.security.oauth2.jwt.JwtDecoder; |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* com.qqkj.WebSecurityConfig |
|
|
|
|
|
* |
|
|
|
|
|
* @author chenyc |
|
|
|
|
|
* @date 2019/10/10 |
|
|
|
|
|
*/ |
|
|
|
|
|
@EnableWebSecurity |
|
|
@EnableWebSecurity |
|
|
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
JwtDecoder jwtDecoder; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
JwtAuthenticationConverter jwtConverter; |
|
|
JwtAuthenticationConverter jwtConverter; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
JwtDecoder jwtDecoder; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void configure(WebSecurity web) throws Exception { |
|
|
public void configure(WebSecurity web) throws Exception { |
|
|
@ -37,13 +30,37 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
http.authorizeRequests().anyRequest().authenticated().and().oauth2Client().and().logout().disable(); |
|
|
|
|
|
http.formLogin().usernameParameter("userloginid"); |
|
|
|
|
|
|
|
|
http.authorizeRequests().antMatchers("/actuator/**","/**/safe/app/auth**", |
|
|
|
|
|
"/**/sys/userTpaInvite/checkInviteId", |
|
|
|
|
|
"/**/sys/user/addUserNoAuth", |
|
|
|
|
|
"/**/sys/user/noauth/detail", |
|
|
|
|
|
"/**/sys/userFans/fansCpd", |
|
|
|
|
|
"/**/sys/userSvr/list", |
|
|
|
|
|
"/**/sys/user/crowd/list", |
|
|
|
|
|
"/**/sys/branch/add", |
|
|
|
|
|
"/**/sys/branch/list", |
|
|
|
|
|
"/**/sys/branch/listBranchNoAuth", |
|
|
|
|
|
"/**/sys/branch/addBranchNoAuth", |
|
|
|
|
|
"/**/sys/dept/listDeptAndChidlDeptByBranchIdNoAuth", |
|
|
|
|
|
"/**/sys/dept/addDeptNoAuth", |
|
|
|
|
|
"/**/sys/userDept/batchEditNoauth", |
|
|
|
|
|
"/**/list/byItemCode", |
|
|
|
|
|
"/**/list/byItemIds", |
|
|
|
|
|
"/**/sys/userTpa/list", |
|
|
|
|
|
"/app/appTpAuth/list", |
|
|
|
|
|
"/**/menuModuleBranch/list", |
|
|
|
|
|
"/**/item/dicts", |
|
|
|
|
|
"/**/list/sysParam", |
|
|
|
|
|
"/swagger-ui.html", |
|
|
|
|
|
"/webjars/**", |
|
|
|
|
|
"/swagger-ui/**", |
|
|
|
|
|
"/swagger-resources/**", |
|
|
|
|
|
"/v2/*", |
|
|
|
|
|
"/csrf", |
|
|
|
|
|
"/").permitAll().anyRequest().authenticated(); |
|
|
|
|
|
http.oauth2Client().and().logout().disable(); |
|
|
http.oauth2Login(); |
|
|
http.oauth2Login(); |
|
|
http.oauth2ResourceServer().jwt().jwtAuthenticationConverter(jwtConverter); |
|
|
|
|
|
http.csrf().disable(); |
|
|
|
|
|
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); |
|
|
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); |
|
|
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);//禁用session |
|
|
|
|
|
|
|
|
http.csrf().disable(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |