From d315903b585995d1c68db28085722943dcaf5423 Mon Sep 17 00:00:00 2001 From: mybloom Date: Wed, 8 Jun 2022 06:58:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20config=ED=8C=8C=EC=9D=BC=EC=97=90=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=86=8D=EC=84=B1=EC=9D=84=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=99=80=EC=84=9C=20=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=EB=A1=9C=20=EC=83=9D=EC=84=B1=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=20(ios-h/airbnb#35)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - @ConfigurationProperties를 이용해서 yml config 파일에서 읽은 속성을 객체로 생성 - @EnableConfigurationProperties를 이용해서 위에서 객체로 생성한 것을 속성으로 사용하고, - @Configuration을 통해서 해당 속성을 사용한 repository를 스프링 빈으로 등록한다. --- .../team4/airbnb/auth/config/OauthConfig.java | 21 +++++++++++++ .../airbnb/auth/config/OauthProperties.java | 30 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 BE/src/main/java/org/team4/airbnb/auth/config/OauthConfig.java create mode 100644 BE/src/main/java/org/team4/airbnb/auth/config/OauthProperties.java diff --git a/BE/src/main/java/org/team4/airbnb/auth/config/OauthConfig.java b/BE/src/main/java/org/team4/airbnb/auth/config/OauthConfig.java new file mode 100644 index 000000000..1f4807b17 --- /dev/null +++ b/BE/src/main/java/org/team4/airbnb/auth/config/OauthConfig.java @@ -0,0 +1,21 @@ +package org.team4.airbnb.auth.config; + +import java.util.Map; +import lombok.RequiredArgsConstructor; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@RequiredArgsConstructor +@Configuration +@EnableConfigurationProperties(OauthProperties.class) +public class OauthConfig { + + private final OauthProperties properties; + + @Bean + public MemoryProviderRepository memoryProviderRepository() { + Map providers = OauthAdapter.getOauthProviders(properties); + return new MemoryProviderRepository(providers); + } +} diff --git a/BE/src/main/java/org/team4/airbnb/auth/config/OauthProperties.java b/BE/src/main/java/org/team4/airbnb/auth/config/OauthProperties.java new file mode 100644 index 000000000..b5cb564a7 --- /dev/null +++ b/BE/src/main/java/org/team4/airbnb/auth/config/OauthProperties.java @@ -0,0 +1,30 @@ +package org.team4.airbnb.auth.config; + +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@Getter +@ConfigurationProperties(prefix = "oauth") +public class OauthProperties { + private final Map users = new HashMap<>(); + + private final Map providers = new HashMap<>(); + + @Getter + @Setter + public static class User { + private String clientId; + private String clientSecret; + private String redirectUri; + } + + @Getter + @Setter + public static class Provider { + private String tokenUri; + private String userInfoUri; + } +}