refactor: GitHub id 기반 관리자 판정으로 인증 구조 정리 - #99
Merged
Conversation
- authOptions를 app/lib/auth.ts로 분리하고 getServerSession(authOptions)를 일관되게 사용 - 관리자 판정 기준을 ADMIN_EMAIL에서 ADMIN_GITHUB_ID(GitHub 숫자 id)로 교체 - 18개 API 라우트의 getServerSession + isAdminSession 반복 패턴을 authz.ts의 getAdminSession/getSession 헬퍼로 통일 - next-auth 모듈 타입을 app/types/next-auth.d.ts로 확장해 session.isAdmin, session.user.id, session.user.githubLogin에 대한 인라인 캐스팅 제거 - atelier 방문자 메시지 저장 시 author.githubId에 githubLogin 대신 session.user.id를 저장하도록 수정 (기존에는 소유권 비교(id)와 저장값(login)이 어긋나 방문자가 자신의 글을 수정/삭제할 수 없었음) - README 환경변수 안내를 ADMIN_GITHUB_ID로 갱신 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
hast에서 className은 공백으로 구분된 다중 클래스를 표현하기 위해 string[]로 취급하는데, descriptionNode/createYoutubeIframe에서 문자열을 그대로 넣고 있어 pnpm 8(Node 18) 환경의 @types/hast 해석에서 타입 에러가 발생했다. 이 PR의 관리자 인증 변경과는 무관한 기존 결함. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
GitHub OAuth 자체는 유지하되(Atelier 방명록 방문자 로그인에 필요), 관리자 인증 구조를 정리했다.
변경사항
authOptions를app/lib/auth.ts로 분리.getServerSession()을 authOptions 없이 호출하던 기존 코드는 session/jwt 콜백이 서버에서 적용되지 않는 문제가 있었음 — 이제 모든 서버 라우트가 authOptions를 통해 세션을 조회한다.ADMIN_EMAIL(이메일)에서ADMIN_GITHUB_ID(GitHub 숫자 id)로 교체. 관리자 여부(session.isAdmin)는auth.ts의 session 콜백에서 한 번만 계산한다.getServerSession()+isAdminSession(session)반복 패턴을app/lib/authz.ts의getAdminSession()(관리자 전용 라우트) /getSession()(전체 세션이 필요한 라우트) 헬퍼로 통일.app/types/next-auth.d.ts로 next-auth 모듈을 확장해session.isAdmin,session.user.id,session.user.githubLogin에 대한 인라인 타입 캐스팅((session as ...))을 전부 제거.author.githubId에githubLogin(계정명 문자열)을 저장하고 있었는데, 삭제/수정 라우트의 소유권 확인은session.user.id(숫자 id)와 비교했다. 값이 서로 달라 방문자는 자신이 쓴 글을 절대 수정/삭제할 수 없었음 —session.user.id를 저장하도록 수정.ADMIN_GITHUB_ID로 갱신.ADMIN_GITHUB_ID환경변수를 설정해야 한다.https://api.github.com/users/{GitHub 아이디}응답의id값을 넣으면 된다. 설정 전까지는 어떤 계정도 관리자로 인식되지 않는다 (기존ADMIN_EMAIL은 더 이상 사용하지 않음).검증 관련 안내
로컬 환경 디스크 공간 부족으로
pnpm type-check/pnpm lint/ pre-commit 훅(lint-staged)을 정상적으로 실행하지 못했다 (node_modules재설치까지 실패). 코드는 눈으로 재확인했지만, 병합 전에 CI 또는 로컬에서pnpm type-check와pnpm lint를 한 번 더 돌려보는 것을 권장한다.🤖 Generated with Claude Code