Skip to content

feat: migrate to GitHub app#121

Open
SoMin-Yoo wants to merge 11 commits intodevelopfrom
feat/migrate-to-github-app
Open

feat: migrate to GitHub app#121
SoMin-Yoo wants to merge 11 commits intodevelopfrom
feat/migrate-to-github-app

Conversation

@SoMin-Yoo
Copy link
Copy Markdown
Collaborator

@SoMin-Yoo SoMin-Yoo commented Feb 27, 2026

🚀 작업 배경

기존 OAuth App의 과도한 권한 요구 문제를 해결하고, 필요한 권한만 세밀하게 제어하기 위해 GitHub App으로 마이그레이션했습니다.


🛠️ 주요 변경 사항

  1. GitHub App 연동 시스템 구축 및 안정화
  • Backend의 JWT 인증 및 Private Key(PKCS#1/8) 로딩 로직을 구현하여 GitHub API 통신 방식을 마이그레이션했습니다.
  • 저장소 연결 시 App 설치 여부를 사전에 검증하는 로직을 추가하고, 미설치 시 사용자 가이드를 제공하는 예외 처리를 강화했습니다.
  1. 온보딩 연동 프로세스 최적화 (Step 5)
  • 사용자가 GitHub App을 설치하면 페이지 이동 없이 즉시 감지할 수 있도록 실시간 폴링(Polling) 로직을 적용했습니다.
  • '설치 단계'와 '연동 완료' 단계를 시각적으로 분리하고, 타임아웃이나 설치 실패 시 사용자가 바로 인지하고 조치할 수 있도록 안내 문구를 세분화했습니다.
  1. 마이페이지(Profile) 사용성 개선
  • 저장소를 변경하거나 권한이 부족할 때, GitHub 설정 페이지로 바로 이동할 수 있는 직속 링크와 구체적인 안내 메시지를 제공하도록 수정했습니다.

🔗 관련 이슈

Copilot AI review requested due to automatic review settings February 27, 2026 12:16
@SoMin-Yoo SoMin-Yoo changed the base branch from main to develop February 27, 2026 12:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the authentication system from GitHub OAuth App to GitHub App to reduce permission requirements and improve security. The migration includes implementing JWT-based authentication for GitHub API communication, adding real-time polling for app installation detection during onboarding, and enhancing user guidance for app installation and permission management.

Changes:

  • Implemented GitHub App integration with JWT authentication and private key loading for secure API communication
  • Added real-time polling mechanism to detect GitHub App installation during onboarding without page navigation
  • Enhanced error handling in profile view to guide users through GitHub App installation when permissions are missing

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
backend/src/main/java/com/ssafy/dash/github/application/GitHubAppService.java New service implementing GitHub App JWT generation, installation token retrieval, and app installation verification
backend/src/main/java/com/ssafy/dash/github/application/GitHubPushEventWorker.java Added token resolution logic to prefer GitHub App tokens over OAuth tokens when processing push events
backend/src/main/java/com/ssafy/dash/onboarding/application/OnboardingService.java Removed webhook registration logic and added GitHub App installation pre-validation
backend/src/main/java/com/ssafy/dash/onboarding/presentation/OnboardingController.java Added endpoint to check GitHub App installation status for repositories
backend/src/main/java/com/ssafy/dash/github/config/GitHubAppProperties.java Configuration properties for GitHub App ID and private key path
backend/src/main/java/com/ssafy/dash/github/config/GitHubConfig.java Configuration class enabling GitHub App and webhook properties
backend/src/main/java/com/ssafy/dash/onboarding/domain/exception/GitHubAppNotInstalledException.java New exception for missing GitHub App installations
backend/src/main/java/com/ssafy/dash/common/exception/ErrorCode.java Added error code for GitHub App not installed scenario
backend/src/main/resources/application.properties Updated OAuth scopes and added GitHub App configuration
backend/pom.xml Added JJWT dependencies for JWT token generation
frontend/src/views/onboarding/OnboardingView.vue Added installation_id query parameter handling to redirect users back to repo step after app installation
frontend/src/views/onboarding/OnboardingStep5Repo.vue Implemented real-time polling for GitHub App installation with visual states and timeout handling
frontend/src/views/user/ProfileView.vue Enhanced error handling to detect app permission issues and guide users to GitHub App settings
frontend/src/api/onboarding.js Added API method to check GitHub App installation status
docker-compose.yml Added GitHub App environment variables and volume mount for private key
.gitignore Added .pem files to prevent committing private keys

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/views/onboarding/OnboardingStep5Repo.vue Outdated
Comment thread frontend/src/views/onboarding/OnboardingStep5Repo.vue
Comment thread frontend/src/views/onboarding/OnboardingStep5Repo.vue Outdated
Comment thread docker-compose.yml Outdated
Comment thread frontend/src/views/user/ProfileView.vue
Comment on lines +77 to +79
console.log('Found installation_id, forcing Step 5 (Repo)');
currentStepIndex.value = 4; // repo 단계로 강제 이동
return;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

After a GitHub App installation, GitHub redirects back with an installation_id query parameter. However, the code forces the user to Step 5 (repo) without considering whether the repository has already been detected. If the user completes installation but returns via GitHub's redirect, they'll be forced back to Step 5 even if they've already completed it. Consider checking if the repository is already configured before forcing the user to Step 5, or clearing the query parameter after processing to prevent loops.

Suggested change
console.log('Found installation_id, forcing Step 5 (Repo)');
currentStepIndex.value = 4; // repo 단계로 강제 이동
return;
console.log('Found installation_id, handling GitHub App callback');
// installation_id 파라미터는 한 번 처리 후 제거하여 루프를 방지합니다.
const { installation_id, ...restQuery } = route.query;
if (installation_id) {
router.replace({ path: route.path, query: restQuery });
}
// 리포지토리가 아직 설정되지 않은 경우에만 리포지토리 단계(4)로 강제 이동합니다.
if (!hasRepo) {
currentStepIndex.value = 4; // repo 단계로 강제 이동
return;
}
// 이미 리포지토리가 설정된 경우에는 일반 온보딩 로직을 계속 진행합니다.

Copilot uses AI. Check for mistakes.
spring.security.oauth2.client.registration.github.client-id=${GITHUB_CLIENT_ID}
spring.security.oauth2.client.registration.github.client-secret=${GITHUB_CLIENT_SECRET}
spring.security.oauth2.client.registration.github.scope=read:user,user:email,repo,admin:repo_hook
spring.security.oauth2.client.registration.github.scope=read:user,user:email
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

OAuth scopes have been reduced from "read:user,user:email,repo,admin:repo_hook" to just "read:user,user:email". While this aligns with the GitHub App migration, if any existing code still relies on the OAuth token to access repository content or manage webhooks, those operations will fail. The PR description mentions migrating to GitHub App tokens, but verify that all OAuth token usage has been migrated to use GitHub App tokens instead.

Suggested change
spring.security.oauth2.client.registration.github.scope=read:user,user:email
spring.security.oauth2.client.registration.github.scope=read:user,user:email,repo,admin:repo_hook

Copilot uses AI. Check for mistakes.
@SoMin-Yoo SoMin-Yoo changed the title Feat: migrate to GitHub app feat: migrate to GitHub app Feb 28, 2026
@SoMin-Yoo SoMin-Yoo requested review from canit0221 and utact February 28, 2026 02:49
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.

[#106] GitHub OAuth App → GitHub App 마이그레이션

4 participants