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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ontime-back/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM openjdk:17
RUN apk add --no-cache tzdata && \
ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
echo "Asia/Seoul" > /etc/timezone
WORKDIR /app
COPY project.jar app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
2 changes: 1 addition & 1 deletion ontime-back/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation 'com.auth0:java-jwt:4.4.0'

// oauth
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SocialAuthController {
content = @Content(
schema = @Schema(
type = "object",
example = "{\n \"accessToken\": \"ya29.xxxxxxx\" }"
example = "{\n \"idToken\": \"eyJhbGxxxxxxx\" ,\n \"refreshToken\": \"\"}}"
)
)
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,32 @@

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Slf4j
@Service
@RequiredArgsConstructor
public class GoogleLoginService {

private final JwtTokenProvider jwtTokenProvider;
private final UserRepository userRepository;
private static final String GOOGLE_USER_INFO_URL = "https://www.googleapis.com/userinfo/v2/me";
private static final String GOOGLE_REVOKE_URL = "https://oauth2.googleapis.com/revoke?token=";

@Value("${spring.security.oauth2.client.registration.google.client-id}")
private String clientId;
private final List<String> validClientIds;

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


public Authentication handleLogin(OAuthGoogleRequestDto oAuthGoogleRequestDto, User user, HttpServletResponse response) throws IOException {
user.updateSocialLoginToken(oAuthGoogleRequestDto.getRefreshToken());
Expand Down Expand Up @@ -127,7 +138,7 @@ public GoogleIdToken.Payload verifyIdentityToken(String identityToken) throws Ex
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(
new NetHttpTransport(),
GsonFactory.getDefaultInstance())
.setAudience(Collections.singletonList(clientId)) // aud 확인
.setAudience(validClientIds) // aud 확인
.build();

GoogleIdToken idToken = verifier.verify(identityToken); // Google의 공개 키를 사용하여 idToken 서명을 검증
Expand Down
Loading