[Feature] 카카오 로그인기능 작성 - #6
Open
hyunnminn wants to merge 2 commits into
Open
Conversation
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.
📌 관련 이슈
Closes #
🛠 작업 내용
config/urls.py:path('auth/social/', include('allauth.urls'))격리 마운트 (기존/auth/login,/auth/signup과 경로 충돌 방지)requirements.txt:django-allauth,python-dotenv,requests추가config/settings.pyINSTALLED_APPS에allauth,allauth.account,allauth.socialaccount,allauth.socialaccount.providers.kakao등록AUTHENTICATION_BACKENDS에ModelBackend(자체 로그인 우선) + allauth 백엔드 추가SOCIALACCOUNT_LOGIN_ON_GET = False— GET 링크 대신 POST 폼 제출 방식으로 CSRF 방어SOCIALACCOUNT_EMAIL_REQUIRED = False,SOCIALACCOUNT_EMAIL_VERIFICATION = "none"— 카카오 미동의 이메일도 가입 허용SOCIALACCOUNT_EMAIL_AUTHENTICATION = False— 이메일 기반 자동 계정 연결 차단 (자체 계정과 카카오 계정을 완전히 분리)LOGIN_REDIRECT_URL = "/"— 로그인 성공 후 리다이렉트 경로 고정SOCIALACCOUNT_PROVIDERS["kakao"]에.env(KAKAO_REST_API_KEY,KAKAO_CLIENT_SECRET)에서 client_id/secret 로드load_dotenv(BASE_DIR / ".env")호출 추가 (기존엔 import만 있고 미호출 상태였음)accounts/adapters.py신규 작성 —KakaoSocialAccountAdapter(SOCIALACCOUNT_ADAPTER)populate_user: username을kakao_{카카오uid}로 고정 (allauth 기본값인 카카오 닉네임 기반 생성 시 자체 계정 username과 네임스페이스가 섞이는 문제 방지)on_authentication_error: 인증 실패 시 allauth 기본 에러 템플릿("Third-Party Login Failure") 대신/login?error=KAKAO_AUTH_DENIED(동의 취소) 또는/login?error=SOCIAL_AUTH_FAILED(그 외 실패)로 리다이렉트📸 스크린샷 (UI 변경 시)
해당 없음 — 프론트 미구현, API/설정 단계 작업
✅ 체크리스트
POST /auth/social/kakao/login/→ 카카오 인가 페이지 302 리다이렉트,on_authentication_error/populate_user단위 테스트로 검증SocialAccount등) 마이그레이션은 라이브러리 내장분이라 별도 생성 불필요POST /auth/signup: 이제AUTHENTICATION_BACKENDS가 2개라auth_login()에backend=인자가 없으면 크래시남 — 다음 PR에서 수정 예정GET /auth/session응답에login_method(카카오/자체 구분) 필드 미추가