반응형
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://cloud.spring.io/spring-cloud-static/spring-cloud-security/2.2.2.RELEASE/reference/html/#_client_token_relay_in_spring_cloud_gateway

https://github.com/spring-cloud-samples/sample-gateway-oauth2login

 

반응형

+ Recent posts