This is the Spring Cloud API Gateway server, which handles routing to appropriate services and checks user authentication and authorization. The service consists of an authentication filter and an optional authentication filter. The optional authentication filter is necessary when users look up products without logging in. Additionally, there are authorization filters for each role, providing flexible authentication and authorization.
brew install redis
sudo apt-get install redis
redis-cli -h host -p port -a password
spring:
cloud:
config:
name: apigateway-service
gateway:
routes:
# product
- id: product-service
uri: lb://PRODUCT-SERVICE
predicates:
- Path=/api/products/**
- Method=GET,POST,OPTIONS,PUT,DELETE
filters:
- RewritePath=/api/products/(?<segment>.*), /$\{segment}
- name: JwtOptionalGatewayFilter
# delivery store manager
- id: delivery-service
uri: lb://DELIVERY-SERVICE
predicates:
- Path=/api/delivery/{variable:.*}/**
- Method=GET,POST,OPTIONS,PUT,DELETE,PATCH
filters:
- RewritePath=/api/delivery/(?<segment>.*), /$\{segment}
- name: JwtValidation
- name: StoreAuthorization
# delivery customer
- id: delivery-service
uri: lb://DELIVERY-SERVICE
predicates:
- Path=/api/delivery/**
- Method=GET,POST,OPTIONS,PUT,DELETE,PATCH
filters:
- RewritePath=/api/delivery/(?<segment>.*), /$\{segment}
- name: JwtValidation
- name: SocialAuthorization
https://www.notion.so/0acd63e526144ac3aeac0bea0413704a?pvs=4
https://www.erdcloud.com/d/PSD5Cgi6GrFQbdxgK
📫 How to reach me [email protected]
📄 Know about my experiences https://www.notion.so/704f524047084978836216b3621dc12e?pvs=4