|
|
@ -2,13 +2,11 @@ package com.xm; |
|
|
|
|
|
|
|
|
import com.mdp.oauth2.client.resource.MdpJwtAuthenticationConverter; |
|
|
import com.mdp.oauth2.client.resource.MdpJwtAuthenticationConverter; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
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.oauth2.jwt.NimbusJwtDecoder; |
|
|
|
|
|
import org.springframework.web.client.RestOperations; |
|
|
|
|
|
|
|
|
import org.springframework.security.oauth2.jwt.JwtDecoder; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* com.qqkj.WebSecurityConfig |
|
|
* com.qqkj.WebSecurityConfig |
|
|
@ -23,11 +21,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
@Autowired |
|
|
@Autowired |
|
|
MdpJwtAuthenticationConverter jwtConverter; |
|
|
MdpJwtAuthenticationConverter jwtConverter; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
RestOperations restOperations; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${spring.security.oauth2.resourceserver.jwt.jwk-set-uri:}") |
|
|
|
|
|
String jwkSetUri=""; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
JwtDecoder jwtDecoder; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void configure(WebSecurity web) throws Exception { |
|
|
public void configure(WebSecurity web) throws Exception { |
|
|
@ -45,7 +41,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
http.oauth2Client().and().logout().disable(); |
|
|
http.oauth2Client().and().logout().disable(); |
|
|
http.formLogin().usernameParameter("userloginid"); |
|
|
http.formLogin().usernameParameter("userloginid"); |
|
|
http.oauth2Login(); |
|
|
http.oauth2Login(); |
|
|
http.oauth2ResourceServer().jwt().decoder(NimbusJwtDecoder.withJwkSetUri(jwkSetUri).restOperations(restOperations).build()).jwtAuthenticationConverter(jwtConverter); |
|
|
|
|
|
|
|
|
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); |
|
|
http.csrf().disable(); |
|
|
http.csrf().disable(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|