From 14400af15691d7ab2ac754d5cfe59f8aa92970d9 Mon Sep 17 00:00:00 2001 From: kimscott Date: Tue, 17 Sep 2019 13:01:50 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9D=B4=ED=8A=B8=EC=9B=A8=EC=9D=B4?= =?UTF-8?q?=20=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/ResourceServerConfiguration.java | 14 +++++++++++++- src/main/resources/application.yml | 14 +++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/example/template/ResourceServerConfiguration.java b/src/main/java/com/example/template/ResourceServerConfiguration.java index 8f6b598..15d09dc 100644 --- a/src/main/java/com/example/template/ResourceServerConfiguration.java +++ b/src/main/java/com/example/template/ResourceServerConfiguration.java @@ -1,4 +1,5 @@ package com.example.template; +import org.springframework.cloud.gateway.config.GlobalCorsProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; @@ -6,6 +7,8 @@ import org.springframework.security.config.annotation.web.reactive.EnableWebFlux 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.web.cors.reactive.CorsConfigurationSource; +import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; import java.security.KeyPair; @@ -20,7 +23,7 @@ public class ResourceServerConfiguration { .cors().and() .csrf().disable() .authorizeExchange() - .pathMatchers("/oauth/**","/login/**","/.well-known/jwks.json").permitAll() + .pathMatchers("/goods/**","/oauth/**","/login/**","/.well-known/jwks.json").permitAll() .anyExchange().authenticated() .and() .oauth2ResourceServer() @@ -30,6 +33,15 @@ public class ResourceServerConfiguration { return http.build(); } +// @Bean +// CorsConfigurationSource corsConfigurationSource( +// GlobalCorsProperties globalCorsProperties) { +// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); +// globalCorsProperties.getCorsConfigurations() +// .forEach(source::registerCorsConfiguration); +// return source; +// } + @Bean public KeyPair makeKeyPair(){ KeyPair keyPair = new KeyStoreKeyFactory( diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9b72eed..e68ce3a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,18 +9,14 @@ spring: oauth2: resourceserver: jwt: - jwk-set-uri: http://localhost:8080/.well-known/jwks.json + jwk-set-uri: http://localhost:8088/.well-known/jwks.json cloud: gateway: routes: - id: product uri: http://localhost:8085 predicates: - - Path=/product/** - - id: goods - uri: http://product:8085 - predicates: - - Path=/goods/** + - Path=/products/**,/goods/** - id: order uri: http://localhost:8081 predicates: @@ -71,11 +67,7 @@ spring: - id: product uri: http://product:8080 predicates: - - Path=/products/** - - id: goods - uri: http://product:8080 - predicates: - - Path=/goods/** + - Path=/products/**,/goods/** - id: order uri: http://order:8080 predicates: