Skip to content

[Mod] google login clientid 설정 수정 및 docker container 한국시간대 설정 #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

jjjh02
Copy link
Contributor

@jjjh02 jjjh02 commented Mar 19, 2025

수정한 코드

  • DockerFile - docker container 한국 시간대로 설정
  • build.gradle - oauth2 설정 제거 (spring security를 통한 oauth 사용안함)
  • SocialAuthController - swagger 수정
  • GoogleLoginService - google client id 수정

관련 내용

웹앱과 ios앱의 구글 client id가 다르기 때문에 idToken 인증을 할때 두개의 client id 경우를 모두 고려해야해서 list로 처리

@Value("${google.web.client-id}")
private String webClientId;

@Value("${google.app.client-id}")
private String appClientId;

private static final List<String> VALID_CLIENT_IDS = List.of(
        webClientId, 
        appClientId  
);

이렇게 진행하는 경우,
@value는 Spring이 객체를 생성한 후에 값을 주입하지만
static final List은 클래스 로드(컴파일 시점)에서 초기화됨
=> webClientId와 appClientId가 아직 null일 때 List.of(webClientId, appClientId)를 실행
-> NullPointerException이 발생 가능

public GoogleLoginService(
        JwtTokenProvider jwtTokenProvider,
        UserRepository userRepository,
        @Value("${google.web.client-id}") String webClientId,
        @Value("${google.app.client-id}") String appClientId
) {
    this.jwtTokenProvider = jwtTokenProvider;
    this.userRepository = userRepository;
    this.validClientIds = List.of(webClientId, appClientId);
}

Spring이 GoogleLoginService 객체를 생성할 때, 생성자를 호출함
-> Spring은 @value가 붙은 webClientId, appClientId를 먼저 읽어옴
-> 생성자 실행 시, List.of(webClientId, appClientId)가 null이 아닌 실제 값으로 초기화됨
-> 정상적으로 validClientIds가 초기화됨

@github-actions github-actions bot closed this Mar 19, 2025
Copy link

실패하는 테스트코드가 있어 PR이 자동으로 닫혔습니다.
Github Action에서 자세한 실패 로그를 확인하고 코드를 수정하세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant