|
|
@ -6,6 +6,8 @@ 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; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* com.qqkj.WebSecurityConfig |
|
|
* com.qqkj.WebSecurityConfig |
|
|
@ -19,6 +21,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
@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 { |
|
|
@ -34,8 +38,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
http.authorizeRequests().anyRequest().authenticated().and().oauth2Client().and().logout().disable(); |
|
|
http.authorizeRequests().anyRequest().authenticated().and().oauth2Client().and().logout().disable(); |
|
|
http.formLogin().usernameParameter("userloginid"); |
|
|
http.formLogin().usernameParameter("userloginid"); |
|
|
http.oauth2Login(); |
|
|
|
|
|
http.oauth2ResourceServer().jwt().jwtAuthenticationConverter(jwtConverter); |
|
|
|
|
|
|
|
|
//http.oauth2Login(); |
|
|
|
|
|
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); |
|
|
|
|
|
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);//禁用session |
|
|
http.csrf().disable(); |
|
|
http.csrf().disable(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|