-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from KCY-Fit-a-Pet/hotfix/106
π OIDC Token deserializer μ€ν¨ (ν μ€νΈ νμ)
- Loading branch information
Showing
24 changed files
with
213 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 26 additions & 40 deletions
66
...pet-app-external-api/src/main/java/kr/co/fitapet/api/apis/auth/mapper/SmsRedisMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,51 @@ | ||
package kr.co.fitapet.api.apis.auth.mapper; | ||
|
||
import kr.co.fitapet.domain.common.redis.sms.service.SmsOauthService; | ||
import kr.co.fitapet.domain.common.redis.sms.service.SmsPasswordService; | ||
import kr.co.fitapet.domain.common.redis.sms.service.SmsRegisterService; | ||
import kr.co.fitapet.domain.common.redis.sms.service.SmsUidService; | ||
import kr.co.fitapet.domain.common.redis.sms.provider.SmsRedisProvider; | ||
import kr.co.fitapet.domain.common.redis.sms.qualify.SmsOauthQualifier; | ||
import kr.co.fitapet.domain.common.redis.sms.qualify.SmsPasswordQualifier; | ||
import kr.co.fitapet.domain.common.redis.sms.qualify.SmsRegisterQualifier; | ||
import kr.co.fitapet.domain.common.redis.sms.qualify.SmsUidQualifier; | ||
import kr.co.fitapet.domain.common.redis.sms.type.SmsPrefix; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Map; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class SmsRedisMapper { | ||
private final SmsOauthService smsOauthService; | ||
private final SmsRegisterService smsRegisterService; | ||
private final SmsPasswordService smsPasswordService; | ||
private final SmsUidService smsUidService; | ||
private final Map<SmsPrefix, SmsRedisProvider> smsProviderMap; | ||
|
||
public SmsRedisMapper( | ||
@SmsOauthQualifier SmsRedisProvider smsOauthService, | ||
@SmsRegisterQualifier SmsRedisProvider smsRegisterService, | ||
@SmsPasswordQualifier SmsRedisProvider smsPasswordService, | ||
@SmsUidQualifier SmsRedisProvider smsUidService | ||
) { | ||
smsProviderMap = Map.of( | ||
SmsPrefix.OAUTH, smsOauthService, | ||
SmsPrefix.REGISTER, smsRegisterService, | ||
SmsPrefix.PASSWORD, smsPasswordService, | ||
SmsPrefix.UID, smsUidService | ||
); | ||
} | ||
|
||
public void saveSmsAuthToken(String phone, String code, SmsPrefix prefix) { | ||
switch (prefix) { | ||
case OAUTH -> smsOauthService.save(phone, code, prefix); | ||
case REGISTER -> smsRegisterService.save(phone, code, prefix); | ||
case PASSWORD -> smsPasswordService.save(phone, code, prefix); | ||
case UID -> smsUidService.save(phone, code, prefix); | ||
} | ||
smsProviderMap.get(prefix).saveSmsAuthToken(phone, code, prefix); | ||
} | ||
|
||
public boolean isCorrectCode(String phone, String code, SmsPrefix prefix) { | ||
return switch (prefix) { | ||
case OAUTH -> smsOauthService.isCorrectCode(phone, code, prefix); | ||
case REGISTER -> smsRegisterService.isCorrectCode(phone, code, prefix); | ||
case PASSWORD -> smsPasswordService.isCorrectCode(phone, code, prefix); | ||
case UID -> smsUidService.isCorrectCode(phone, code, prefix); | ||
}; | ||
return smsProviderMap.get(prefix).isCorrectCode(phone, code, prefix); | ||
} | ||
|
||
public boolean isExistsCode(String phone, SmsPrefix prefix) { | ||
return switch (prefix) { | ||
case OAUTH -> smsOauthService.isExistsCode(phone, prefix); | ||
case REGISTER -> smsRegisterService.isExistsCode(phone, prefix); | ||
case PASSWORD -> smsPasswordService.isExistsCode(phone, prefix); | ||
case UID -> smsUidService.isExistsCode(phone, prefix); | ||
}; | ||
return smsProviderMap.get(prefix).isExistsCode(phone, prefix); | ||
} | ||
|
||
public void removeCode(String phone, SmsPrefix prefix) { | ||
switch (prefix) { | ||
case OAUTH -> smsOauthService.removeCode(phone, prefix); | ||
case REGISTER -> smsRegisterService.removeCode(phone, prefix); | ||
case PASSWORD -> smsPasswordService.removeCode(phone, prefix); | ||
case UID -> smsUidService.removeCode(phone, prefix); | ||
}; | ||
smsProviderMap.get(prefix).removeCode(phone, prefix); | ||
} | ||
|
||
public LocalDateTime getExpiredTime(String phone, SmsPrefix prefix) { | ||
return switch (prefix) { | ||
case OAUTH -> smsOauthService.getExpiredTime(phone, prefix); | ||
case REGISTER -> smsRegisterService.getExpiredTime(phone, prefix); | ||
case PASSWORD -> smsPasswordService.getExpiredTime(phone, prefix); | ||
case UID -> smsUidService.getExpiredTime(phone, prefix); | ||
}; | ||
return smsProviderMap.get(prefix).getExpiredTime(phone, prefix); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...l-api/src/main/java/kr/co/fitapet/api/apis/oauth/mapper/OauthApplicationConfigMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package kr.co.fitapet.api.apis.oauth.mapper; | ||
|
||
import kr.co.fitapet.infra.client.oauth.OauthApplicationConfig; | ||
import kr.co.fitapet.infra.client.oauth.provider.apple.AppleApplicationConfig; | ||
import kr.co.fitapet.infra.client.oauth.provider.google.GoogleApplicationConfig; | ||
import kr.co.fitapet.infra.client.oauth.provider.kakao.KakaoApplicationConfig; | ||
import kr.co.fitapet.infra.client.oauth.type.Provider; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Map; | ||
|
||
@Component | ||
public class OauthApplicationConfigMapper { | ||
private final Map<Provider, OauthApplicationConfig> oauthApplicationConfigMap; | ||
|
||
public OauthApplicationConfigMapper( | ||
KakaoApplicationConfig kakaoApplicationConfig, | ||
GoogleApplicationConfig googleApplicationConfig, | ||
AppleApplicationConfig appleApplicationConfig | ||
) { | ||
this.oauthApplicationConfigMap = Map.of( | ||
Provider.KAKAO, kakaoApplicationConfig, | ||
Provider.GOOGLE, googleApplicationConfig, | ||
Provider.APPLE, appleApplicationConfig | ||
); | ||
} | ||
|
||
public OauthApplicationConfig getOauthApplicationConfig(Provider provider) { | ||
return oauthApplicationConfigMap.get(provider); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...app-external-api/src/main/java/kr/co/fitapet/api/apis/oauth/mapper/OauthClientMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package kr.co.fitapet.api.apis.oauth.mapper; | ||
|
||
import kr.co.fitapet.infra.client.oauth.OauthApplicationConfig; | ||
import kr.co.fitapet.infra.client.oauth.OauthClient; | ||
import kr.co.fitapet.infra.client.oauth.dto.OIDCPublicKeyResponse; | ||
import kr.co.fitapet.infra.client.oauth.provider.apple.AppleOauthClient; | ||
import kr.co.fitapet.infra.client.oauth.provider.google.GoogleOauthClient; | ||
import kr.co.fitapet.infra.client.oauth.provider.kakao.KakaoOauthClient; | ||
import kr.co.fitapet.infra.client.oauth.type.Provider; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Map; | ||
|
||
@Component | ||
public class OauthClientMapper { | ||
private final Map<Provider, OauthClient> oauthClientMap; | ||
private final OauthApplicationConfigMapper oauthApplicationConfigMapper; | ||
|
||
public OauthClientMapper( | ||
KakaoOauthClient kakaoOauthClient, | ||
GoogleOauthClient googleOauthClient, | ||
AppleOauthClient appleOauthClient, | ||
OauthApplicationConfigMapper oauthApplicationConfigMapper | ||
) { | ||
this.oauthClientMap = Map.of( | ||
Provider.KAKAO, kakaoOauthClient, | ||
Provider.GOOGLE, googleOauthClient, | ||
Provider.APPLE, appleOauthClient | ||
); | ||
this.oauthApplicationConfigMapper = oauthApplicationConfigMapper; | ||
} | ||
|
||
public OIDCPublicKeyResponse getPublicKeyResponse(Provider provider) { | ||
return oauthClientMap.get(provider).getOIDCPublicKey(); | ||
} | ||
|
||
public OauthApplicationConfig getOauthApplicationConfig(Provider provider) { | ||
return oauthApplicationConfigMapper.getOauthApplicationConfig(provider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Domain |
Oops, something went wrong.