Skip to content

Commit

Permalink
fix: apple client_secret yml에서 읽게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KarmaPol committed Feb 12, 2024
1 parent 8acc209 commit f48d400
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public class WebSecurityConfig {
private final OAuth2UserService oAuth2UserService;
private final OAuth2AuthSuccessHandler oAuth2AuthSuccessHandler;
private final HttpCookieOAuth2AuthorizationRequestRepository httpCookieOAuth2AuthorizationRequestRepository;
private final CustomRequestEntityConverter customRequestEntityConverter;

@Bean
public OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient() {
DefaultAuthorizationCodeTokenResponseClient accessTokenResponseClient = new DefaultAuthorizationCodeTokenResponseClient();
accessTokenResponseClient.setRequestEntityConverter(new CustomRequestEntityConverter());
accessTokenResponseClient.setRequestEntityConverter(customRequestEntityConverter);

return accessTokenResponseClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.RequestEntity;
Expand All @@ -26,11 +27,12 @@

@Slf4j
@Component
@PropertySource("classpath:application-security.yml")
public class CustomRequestEntityConverter implements Converter<OAuth2AuthorizationCodeGrantRequest, RequestEntity<?>> {

private OAuth2AuthorizationCodeGrantRequestEntityConverter defaultConverter;
@Value("${spring.security.oauth2.client.registration.apple.clientSecret}")
private String APPLE_CLIENT_SECRET;
@Value("${spring.security.oauth2.client.registration.apple.client-secret}")
private String appleClientSecret;

public CustomRequestEntityConverter() {
defaultConverter = new OAuth2AuthorizationCodeGrantRequestEntityConverter();
Expand All @@ -44,7 +46,7 @@ public RequestEntity<?> convert(OAuth2AuthorizationCodeGrantRequest req) {
//Apple일 경우 secret key를 동적으로 세팅
if (registrationId.contains("apple")) {
params.set("client_secret",
createAppleClientSecret(params.get("client_id").get(0), APPLE_CLIENT_SECRET));
createAppleClientSecret(params.get("client_id").get(0), appleClientSecret));
}
return new RequestEntity<>(params, entity.getHeaders(),
entity.getMethod(), entity.getUrl());
Expand Down

0 comments on commit f48d400

Please sign in to comment.