Skip to content

[Refactor/social login handler]#89

Merged
ekgns33 merged 7 commits intomainfrom
refactor/social-login-handler
May 10, 2025
Merged

[Refactor/social login handler]#89
ekgns33 merged 7 commits intomainfrom
refactor/social-login-handler

Conversation

@ekgns33
Copy link
Copy Markdown
Contributor

@ekgns33 ekgns33 commented May 10, 2025

작업내역

소셜로그인 로직의 반복되는 부분을 템플릿 패턴으로 추상화했습니다.

  1. JWT 검증.
  2. 소셜 OIDC로 리소스 조회
  3. OAuth 정보 확인
  4. Runimo Service JWT 발급
  • 구현체를 선택하는 부분은 추상화하지 않았습니다 (API 스펙이 바뀌는 경우라 보수적으로 리팩토링했어요)

RefreshToken 로직

  • 테스트 도중 리프레쉬토큰을 저장하는 과정에서 비즈니스로직(토큰 만료)가 포함되어 이를 수정했습니다.
    • 저장시에는 id로 엔티티 조회.
    • 리프레쉬 토큰 조회시에는 토큰 만료 필터링 쿼리 사용

Summary by CodeRabbit

  • New Features

    • Introduced a unified social login framework with a new interface for social login handlers.
    • Added abstract and concrete classes for Apple and Kakao login, enabling streamlined OIDC-based authentication and signup flows.
    • Implemented thread-local context management for Apple authentication tokens.
  • Refactor

    • Migrated and reorganized Apple and Kakao login handlers into a new package structure for improved maintainability.
    • Replaced direct usage of implementation classes with interfaces in tests for better abstraction.
    • Updated repository logic for refresh tokens to improve token expiration handling.
  • Bug Fixes

    • Adjusted test setup and token generation for more reliable and isolated authentication tests.
  • Style

    • Improved code formatting and indentation across multiple files for consistency.
  • Documentation

    • Added and updated Javadoc comments for key authentication repository methods.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2025

Walkthrough

This update restructures the social login system by introducing a generic OIDC login handler framework, moving Apple and Kakao login logic into new provider-specific handler classes under a unified package. The previous concrete handler classes are removed. Supporting classes and interfaces are refactored or added for modularity. Minor formatting, indentation, and import adjustments are also applied throughout the codebase and related tests.

Changes

File(s) Change Summary
.../auth/controller/request/AuthSignupConverter.java
.../auth/domain/RefreshToken.java
.../auth/repository/InMemoryTokenRepository.java
.../auth/repository/JwtTokenRepository.java
.../auth/repository/RefreshTokenJpaRepository.java
.../auth/service/TokenRefreshService.java
.../auth/test/TestAuthController.java
.../auth/test/TestAuthService.java
Reformatted code for indentation and spacing; no logic changes.
.../auth/repository/DatabaseTokenRepository.java Modified token retrieval to filter by expiration, moved cutoff calculation, added Javadoc comments.
.../auth/service/OidcService.java
.../user/service/WithdrawService.java
Updated import statements to reflect new package structure for Apple/Kakao handlers.
.../auth/service/apple/AppleLoginHandler.java
.../auth/service/kakao/KakaoLoginHandler.java
Deleted old Apple and Kakao login handler classes.
.../auth/service/login/OIDCLoginHandler.java Added new abstract OIDCLoginHandler class implementing the social login flow template.
.../auth/service/login/SocialLoginHandler.java Introduced new SocialLoginHandler interface for social login handlers.
.../auth/service/login/apple/AppleAuthContext.java Added new AppleAuthContext for thread-local Apple token storage.
.../auth/service/login/apple/AppleLoginHandler.java Added new AppleLoginHandler class extending OIDCLoginHandler for Apple login logic.
.../auth/service/login/apple/AppleTokenVerifier.java
.../auth/service/login/apple/AppleUserInfo.java
.../auth/service/login/kakao/KakaoTokenVerifier.java
.../auth/service/login/kakao/KakaoUserInfo.java
Changed package declarations to reflect new handler structure; removed unused imports.
.../auth/service/login/kakao/KakaoLoginHandler.java Added new KakaoLoginHandler class extending OIDCLoginHandler for Kakao login logic.
.../auth/controller/AuthAcceptanceTest.java Updated test logic to use new token generation, adjusted imports, and improved test setup/cleanup.
.../auth/controller/TokenRefreshAcceptanceTest.java Updated imports to match new package structure for Kakao classes.
.../auth/service/SignUpUsecaseTest.java
.../rewards/RewardTest.java
.../user/api/UserItemAcceptanceTest.java
Changed field types from implementation to interface for sign-up use case in tests.

Sequence Diagram(s)

Social Login Flow with OIDCLoginHandler

sequenceDiagram
    participant Client
    participant OIDCLoginHandler
    participant ProviderLoginHandler (Apple/Kakao)
    participant OAuthInfoRepository
    participant SignupTokenRepository
    participant JwtTokenFactory
    participant TokenRefreshService

    Client->>ProviderLoginHandler: validateAndLogin(params)
    ProviderLoginHandler->>OIDCLoginHandler: validateAndLogin(params)
    OIDCLoginHandler->>ProviderLoginHandler: extractProviderId(params)
    ProviderLoginHandler-->>OIDCLoginHandler: providerId

    OIDCLoginHandler->>OAuthInfoRepository: findByProviderId(providerId)
    alt User exists
        OIDCLoginHandler->>JwtTokenFactory: generateTokenPair(user)
        OIDCLoginHandler->>TokenRefreshService: putRefreshToken(userId, refreshToken)
        OIDCLoginHandler-->>Client: AuthResult (login success, tokens)
    else User not found
        OIDCLoginHandler->>ProviderLoginHandler: createProviderSpecificToken(tokenId, providerId, params)
        ProviderLoginHandler-->>OIDCLoginHandler: SignupToken
        OIDCLoginHandler->>SignupTokenRepository: save(SignupToken)
        OIDCLoginHandler->>JwtTokenFactory: generateSignupTemporalToken(SignupToken)
        OIDCLoginHandler-->>Client: AuthResult (signup needed, temporal token)
    end
Loading

Poem

In the warren of code, a new path is spun,
Social logins unified, their journeys begun.
Apple and Kakao, now handled with flair,
Abstracted and tidy, each bunny-aware.
With tokens in pockets and logins in flow,
This rabbit hops forward—onward we go!
🥕✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 77f8ba6 and 2d2854e.

📒 Files selected for processing (27)
  • src/main/java/org/runimo/runimo/auth/controller/request/AuthSignupConverter.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/domain/RefreshToken.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/repository/DatabaseTokenRepository.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/repository/InMemoryTokenRepository.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/repository/JwtTokenRepository.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/repository/RefreshTokenJpaRepository.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/OidcService.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/TokenRefreshService.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/apple/AppleLoginHandler.java (0 hunks)
  • src/main/java/org/runimo/runimo/auth/service/kakao/KakaoLoginHandler.java (0 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/OIDCLoginHandler.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/SocialLoginHandler.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/apple/AppleAuthContext.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/apple/AppleLoginHandler.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/apple/AppleTokenVerifier.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/apple/AppleUserInfo.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/kakao/KakaoLoginHandler.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/kakao/KakaoTokenVerifier.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/login/kakao/KakaoUserInfo.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/test/TestAuthController.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/test/TestAuthService.java (1 hunks)
  • src/main/java/org/runimo/runimo/user/service/WithdrawService.java (1 hunks)
  • src/test/java/org/runimo/runimo/auth/controller/AuthAcceptanceTest.java (4 hunks)
  • src/test/java/org/runimo/runimo/auth/controller/TokenRefreshAcceptanceTest.java (1 hunks)
  • src/test/java/org/runimo/runimo/auth/service/SignUpUsecaseTest.java (1 hunks)
  • src/test/java/org/runimo/runimo/rewards/RewardTest.java (2 hunks)
  • src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java (2 hunks)
💤 Files with no reviewable changes (2)
  • src/main/java/org/runimo/runimo/auth/service/kakao/KakaoLoginHandler.java
  • src/main/java/org/runimo/runimo/auth/service/apple/AppleLoginHandler.java

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@jeeheaG jeeheaG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다~

@ekgns33 ekgns33 merged commit 1d5166b into main May 10, 2025
3 checks passed
@ekgns33 ekgns33 deleted the refactor/social-login-handler branch May 10, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants