-
Notifications
You must be signed in to change notification settings - Fork 4
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
[BE] OAuth 로그인 인증 시스템 초기 구축 #21
Merged
viaunixue
merged 106 commits into
neonadeuli-project:develop
from
viaunixue:feat/google-oauth-impl
Oct 19, 2024
Merged
[BE] OAuth 로그인 인증 시스템 초기 구축 #21
viaunixue
merged 106 commits into
neonadeuli-project:develop
from
viaunixue:feat/google-oauth-impl
Oct 19, 2024
Conversation
This file contains 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
- 인증, 인가 라이브러리 authlib 추가
- postgresql DB 설정 재조정
- uvicorn 루트 경로 src 디렉토리로 설정
- auth_middleware 메소드 업데이트 - core/auth/dependencies의 get_current_user 사용
- 액세스 토큰 생성 함수 구현 - 토큰 검증 함수 추가
- UserRole 메소드 추가
- Google OAuth 클라이언트 설정 추가 - setup_oauth 메소드 구현
- `/login/{provider}` 엔드포인트 추가 - `/auth/{provider}/callback` 엔드포인트 구현
- UserBase 클래스에 email, name 필드 추가
- UserCreate 클래스에 password, profile_image 필드 추가
- UserResponse 클래스에 id, is_active, created_at 필드 추가
- UserUpdate 클래스에 선택적 필드 추가
- get_authorization_url, get_user_info 메서드 구현
- 이메일을 통한 유저 조회 쿼리 추가 - 유저 생성 쿼리 추가
- get_current_user 함수 구현 - OAuth2PasswordBearer 설정
- /core/auth - /domains/user/auth - /domains/user/schemas - /domains/user/schemas/user
- 암호 해시화, 암호 검증 메소드 추가
- password 컬럼 추가 - last_login 컬럼 nullable=True 옵션 설정
- is_active 값 추가 (기본값 True) - password 값 None 옵션 추가
- 이름 최소 1글자 ~ 최대 100글자 옵션 추가
- state 값 매개변수 추가 - @classmethod 어노테이션 제거 - 토큰에서 user_info 추출 로직 수정 - GoogleUserInfo 응답 값으로 반환
This was
linked to
issues
Oct 17, 2024
PracticeKJY
approved these changes
Oct 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다.
Miaash
approved these changes
Oct 18, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다.
- Redirect URI, Authorize URL, Token URL, Userinfo URL
- authlib 사용 대신 직접 redis로 state 관리
- refresh 토큰 갱신 버튼 추가
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.
💡 작업 내용
OAuth 구현 및 인증 업데이트
토큰 관리를 위한 Redis 통합
Back-end API 업데이트
Front-end 개선
버그 수정 및 개선
🫨 고민한 부분
a. 새로고침 토큰은 HttpOnly 쿠키로 저장되므로 JavaScript에서 직접 접근 불가
a. 사용자가 페이지를 새로 고치거나 새 URL로 이동할 때마다 새 액세스 토큰을 얻기 위해 백엔드에 요청을 보냅니다.
b. 이 요청에는 HttpOnly 쿠키로 저장되므로 브라우저에서 자동으로 전송하는 새로 고침 토큰이 포함
a. 백엔드는 새로 고침 토큰을 확인하고 유효한 경우 프런트엔드에 새로운 액세스 토큰을 발급
b. 새 액세스 토큰은 API 호출 시 안전하고 임시적으로 사용할 수 있도록 JavaScript 개인 변수에 저장
📌 중점적으로 볼 부분
OAuth 상태 및 새로 고침 토큰을 저장하기 위한 값을 Redis 에 저장합니다.
/auth/{provider}/callback
엔드포인트가 잘 작동하는지 확인 부탁드립니다.🎯 테스트 결과
🎇 동작 화면
📗 참고 자료 (선택)
→ 사용방법
./start-dev.sh
명령어 실행sudo losf -i :{포트번호}
명령어로 PID 번호 확인하고sudo kill -9 {PID번호}
명령어로 포트 정리 필수!🙏리뷰 요구사항(선택)
🚩 후속 작업 (선택)
✅ 셀프 체크리스트
💫 기타사항
close #17 #18 #10