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; + } +}