반응형
plugins {
id 'org.springframework.boot' version '2.7.5'
}
...
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
spring:
cloud:
gateway:
routes:
- id: test
uri: http://httpbin.org
predicates:
- Path=/get
filters:
- TokenRelay=
security:
oauth2:
client:
registration:
login-client:
provider: uaa
client-id: login-client
client-secret: secret
authorization-grant-type: authorization_code
scope: openid,profile,email,resource.read
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
provider:
uaa:
authorization-uri: http://localhost:8090/uaa/oauth/authorize
token-uri: http://localhost:8090/uaa/oauth/token
user-info-uri: http://localhost:8090/uaa/userinfo
user-name-attribute: sub
jwk-set-uri: http://localhost:8090/uaa/token_keys
IDP
https://github.com/spring-cloud-samples/sample-gateway-oauth2login
수정사항
uaa-server/build.gradle
installUrl = 'https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.43/bin/apache-tomcat-8.5.43.zip'
=> installUrl = 'http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.43/bin/apache-tomcat-8.5.43.zip'
uaa-server/uaa.yml
redirect-uri: http://localhost:8080/login/oauth2/code/login-client
=> 자신 redirect uri로 설정
참고
https://www.baeldung.com/spring-cloud-gateway-oauth2
https://jainkku.tistory.com/m/90
https://github.com/spring-cloud-samples/sample-gateway-oauth2login
반응형
'Spring > Spring Cloud' 카테고리의 다른 글
[Spring Cloud Gateway] 라우팅 동적반영(refresh) (0) | 2024.03.17 |
---|---|
Spring Cloud Gateway 다중 포트 가능 여부 (0) | 2022.10.24 |
Spring Cloud Gateway (0) | 2022.10.24 |