게이트웨이 인증 코드 수정 및 버전 증가
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.1.1.RELEASE</version>
|
<version>2.3.2.RELEASE</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.example</groupId>
|
<groupId>com.example</groupId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
|
<spring-cloud.version>Hoxton.SR6</spring-cloud.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.example.template;
|
|
||||||
|
|
||||||
import com.nimbusds.jose.jwk.JWKSet;
|
|
||||||
import com.nimbusds.jose.jwk.RSAKey;
|
|
||||||
import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.security.KeyPair;
|
|
||||||
import java.security.Principal;
|
|
||||||
import java.security.interfaces.RSAPublicKey;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@FrameworkEndpoint
|
|
||||||
@RestController
|
|
||||||
public class JwkSetEndpointConfiguration {
|
|
||||||
KeyPair keyPair;
|
|
||||||
|
|
||||||
public JwkSetEndpointConfiguration(KeyPair keyPair) {
|
|
||||||
this.keyPair = keyPair;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/.well-known/jwks.json")
|
|
||||||
@ResponseBody
|
|
||||||
public Map<String, Object> getKey(Principal principal) {
|
|
||||||
RSAPublicKey publicKey = (RSAPublicKey) this.keyPair.getPublic();
|
|
||||||
RSAKey key = new RSAKey.Builder(publicKey).build();
|
|
||||||
return new JWKSet(key).toJSONObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
package com.example.template;
|
package com.example.template;
|
||||||
|
|
||||||
import org.springframework.cloud.gateway.config.GlobalCorsProperties;
|
import org.springframework.cloud.gateway.config.GlobalCorsProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
||||||
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
||||||
import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
|
|
||||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||||
import org.springframework.web.cors.reactive.CorsConfigurationSource;
|
import org.springframework.web.cors.reactive.CorsConfigurationSource;
|
||||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
import java.security.KeyPair;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebFluxSecurity
|
@EnableWebFluxSecurity
|
||||||
public class ResourceServerConfiguration {
|
public class ResourceServerConfiguration {
|
||||||
@@ -41,14 +38,4 @@ public class ResourceServerConfiguration {
|
|||||||
.forEach(source::registerCorsConfiguration);
|
.forEach(source::registerCorsConfiguration);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public KeyPair makeKeyPair(){
|
|
||||||
KeyPair keyPair = new KeyStoreKeyFactory(
|
|
||||||
new ClassPathResource("server.jks"), "qweqwe".toCharArray())
|
|
||||||
.getKeyPair("uengine", "qweqwe".toCharArray());
|
|
||||||
return keyPair;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ spring:
|
|||||||
oauth2:
|
oauth2:
|
||||||
resourceserver:
|
resourceserver:
|
||||||
jwt:
|
jwt:
|
||||||
jwk-set-uri: http://localhost:8088/.well-known/jwks.json
|
jwk-set-uri: http://localhost:8090/.well-known/jwks.json
|
||||||
cloud:
|
cloud:
|
||||||
gateway:
|
gateway:
|
||||||
routes:
|
routes:
|
||||||
@@ -56,7 +56,7 @@ spring:
|
|||||||
oauth2:
|
oauth2:
|
||||||
resourceserver:
|
resourceserver:
|
||||||
jwt:
|
jwt:
|
||||||
jwk-set-uri: http://localhost:8080/.well-known/jwks.json
|
jwk-set-uri: http://oauth:8080/.well-known/jwks.json
|
||||||
cloud:
|
cloud:
|
||||||
gateway:
|
gateway:
|
||||||
routes:
|
routes:
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user