게이트웨이 부분 수정
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
package com.example.template;
|
package com.example.template;
|
||||||
|
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.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.config.web.server.ServerHttpSecurity;
|
||||||
import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
|
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.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
|
|
||||||
@@ -20,7 +23,7 @@ public class ResourceServerConfiguration {
|
|||||||
.cors().and()
|
.cors().and()
|
||||||
.csrf().disable()
|
.csrf().disable()
|
||||||
.authorizeExchange()
|
.authorizeExchange()
|
||||||
.pathMatchers("/oauth/**","/login/**","/.well-known/jwks.json").permitAll()
|
.pathMatchers("/goods/**","/oauth/**","/login/**","/.well-known/jwks.json").permitAll()
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
.and()
|
.and()
|
||||||
.oauth2ResourceServer()
|
.oauth2ResourceServer()
|
||||||
@@ -30,6 +33,15 @@ public class ResourceServerConfiguration {
|
|||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// CorsConfigurationSource corsConfigurationSource(
|
||||||
|
// GlobalCorsProperties globalCorsProperties) {
|
||||||
|
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
// globalCorsProperties.getCorsConfigurations()
|
||||||
|
// .forEach(source::registerCorsConfiguration);
|
||||||
|
// return source;
|
||||||
|
// }
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public KeyPair makeKeyPair(){
|
public KeyPair makeKeyPair(){
|
||||||
KeyPair keyPair = new KeyStoreKeyFactory(
|
KeyPair keyPair = new KeyStoreKeyFactory(
|
||||||
|
|||||||
@@ -9,18 +9,14 @@ spring:
|
|||||||
oauth2:
|
oauth2:
|
||||||
resourceserver:
|
resourceserver:
|
||||||
jwt:
|
jwt:
|
||||||
jwk-set-uri: http://localhost:8080/.well-known/jwks.json
|
jwk-set-uri: http://localhost:8088/.well-known/jwks.json
|
||||||
cloud:
|
cloud:
|
||||||
gateway:
|
gateway:
|
||||||
routes:
|
routes:
|
||||||
- id: product
|
- id: product
|
||||||
uri: http://localhost:8085
|
uri: http://localhost:8085
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/product/**
|
- Path=/products/**,/goods/**
|
||||||
- id: goods
|
|
||||||
uri: http://product:8085
|
|
||||||
predicates:
|
|
||||||
- Path=/goods/**
|
|
||||||
- id: order
|
- id: order
|
||||||
uri: http://localhost:8081
|
uri: http://localhost:8081
|
||||||
predicates:
|
predicates:
|
||||||
@@ -71,11 +67,7 @@ spring:
|
|||||||
- id: product
|
- id: product
|
||||||
uri: http://product:8080
|
uri: http://product:8080
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/products/**
|
- Path=/products/**,/goods/**
|
||||||
- id: goods
|
|
||||||
uri: http://product:8080
|
|
||||||
predicates:
|
|
||||||
- Path=/goods/**
|
|
||||||
- id: order
|
- id: order
|
||||||
uri: http://order:8080
|
uri: http://order:8080
|
||||||
predicates:
|
predicates:
|
||||||
|
|||||||
Reference in New Issue
Block a user