게이트웨이 부분 수정

This commit is contained in:
kimscott
2019-09-17 13:01:50 +09:00
parent b9f3d3b872
commit 14400af156
2 changed files with 16 additions and 12 deletions

View File

@@ -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(

View File

@@ -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: