-
Notifications
You must be signed in to change notification settings - Fork 0
병합해주세요 (#16) #18
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
Merged
Merged
병합해주세요 (#16) #18
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| *.egg | ||
| *.egg-info/ | ||
| dist/ | ||
| build/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.whl | ||
| .installed.cfg | ||
|
|
||
| # Virtual environments | ||
| .venv/ | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| .coverage | ||
| htmlcov/ | ||
| .tox/ | ||
|
|
||
| # IDEs | ||
| .idea/ | ||
| .vscode/ | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # Environment variables | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Node | ||
| node_modules/ | ||
| npm-debug.log* | ||
|
|
||
| # Distribution | ||
| *.tar.gz | ||
| *.zip |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from datetime import datetime, timedelta | ||
|
|
||
| from secrets import compare_digest, randbelow, token_urlsafe | ||
| import base64 | ||
| import os | ||
|
|
@@ -7,7 +7,7 @@ | |
| from fastapi import APIRouter, Depends, HTTPException, Request, status | ||
| from fastapi.security import OAuth2PasswordRequestForm | ||
| from typing import Optional, cast | ||
| from pydantic import BaseModel, EmailStr | ||
|
|
||
| from sqlalchemy.orm import Session | ||
| from webauthn import ( | ||
| generate_authentication_options, | ||
|
|
@@ -82,8 +82,7 @@ class UserResponse(BaseModel): | |
| business_registration_number: Optional[str] = None | ||
| representative_name: Optional[str] = None | ||
|
|
||
| class Config: | ||
| from_attributes = True | ||
| model_config = ConfigDict(from_attributes=True) | ||
|
|
||
|
Comment on lines
82
to
86
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback |
||
|
|
||
| class Token(BaseModel): | ||
|
|
@@ -254,7 +253,7 @@ class PasswordRecoveryResetResponse(BaseModel): | |
|
|
||
|
|
||
| def _issue_recovery_token(prefix: str) -> tuple[str, datetime]: | ||
| expires_at = datetime.utcnow() + timedelta(minutes=10) | ||
|
|
||
| return f"{prefix}_{token_urlsafe(24)}", expires_at | ||
|
|
||
|
Comment on lines
255
to
258
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback |
||
|
|
||
|
|
@@ -273,7 +272,7 @@ def _normalize_password_recovery_scope(scope: str) -> str: | |
|
|
||
|
|
||
| def _purge_expired_password_recovery_sessions() -> None: | ||
| now = datetime.utcnow() | ||
|
|
||
| expired_tokens = [ | ||
| session_token | ||
| for session_token, session_state in _password_recovery_store.items() | ||
|
|
@@ -380,7 +379,7 @@ def start_passkey_registration( | |
| "user_id": int(user.id), | ||
| "challenge": _to_base64url(options.challenge), | ||
| "device_label": str(payload.device_label or "이 기기 패스키").strip() or "이 기기 패스키", | ||
| "expires_at": datetime.utcnow() + timedelta(minutes=5), | ||
| "expires_at": datetime.now(timezone.utc) + timedelta(minutes=5), | ||
| "user_handle": user_handle, | ||
| "rp_id": rp_id, | ||
| "expected_origin": expected_origin, | ||
|
|
@@ -403,7 +402,7 @@ def finish_passkey_registration( | |
| raise HTTPException(status_code=404, detail="패스키 등록 세션을 찾을 수 없습니다") | ||
|
|
||
| expires_at = state.get("expires_at") | ||
| if not isinstance(expires_at, datetime) or expires_at <= datetime.utcnow(): | ||
| if not isinstance(expires_at, datetime) or expires_at <= datetime.now(timezone.utc): | ||
| _passkey_registration_store.pop(payload.registration_token, None) | ||
| raise HTTPException(status_code=410, detail="패스키 등록 세션이 만료되었습니다") | ||
|
|
||
|
|
@@ -430,7 +429,7 @@ def finish_passkey_registration( | |
| user.passkey_public_key = _to_base64url(verification.credential_public_key) | ||
| user.passkey_device_label = str(state.get("device_label") or "이 기기 패스키") | ||
| user.passkey_sign_count = int(verification.sign_count) | ||
| user.passkey_registered_at = datetime.utcnow() | ||
| user.passkey_registered_at = datetime.now(timezone.utc) | ||
| db.add(user) | ||
| db.commit() | ||
| _passkey_registration_store.pop(payload.registration_token, None) | ||
|
|
@@ -465,7 +464,7 @@ def start_passkey_login( | |
| ) | ||
| _passkey_login_store[str(user.email)] = { | ||
| "challenge": _to_base64url(options.challenge), | ||
| "expires_at": datetime.utcnow() + timedelta(minutes=5), | ||
| "expires_at": datetime.now(timezone.utc) + timedelta(minutes=5), | ||
| "credential_id": str(user.passkey_credential_id), | ||
| "rp_id": rp_id, | ||
| "expected_origin": expected_origin, | ||
|
|
@@ -492,7 +491,7 @@ def finish_passkey_login( | |
| raise HTTPException(status_code=404, detail="패스키 로그인 세션을 찾을 수 없습니다") | ||
|
|
||
| expires_at = state.get("expires_at") | ||
| if not isinstance(expires_at, datetime) or expires_at <= datetime.utcnow(): | ||
| if not isinstance(expires_at, datetime) or expires_at <= datetime.now(timezone.utc): | ||
| _passkey_login_store.pop(str(user.email), None) | ||
| raise HTTPException(status_code=410, detail="패스키 로그인 세션이 만료되었습니다") | ||
|
|
||
|
|
@@ -581,7 +580,7 @@ def verify_password_recovery_identity(payload: PasswordRecoveryVerifyIdentityReq | |
| raise HTTPException(status_code=404, detail="복구 세션을 찾을 수 없습니다") | ||
|
|
||
| expires_at = session_state.get("expires_at") | ||
| if not isinstance(expires_at, datetime) or expires_at <= datetime.utcnow(): | ||
| if not isinstance(expires_at, datetime) or expires_at <= datetime.now(timezone.utc): | ||
| _password_recovery_store.pop(payload.recovery_session_token, None) | ||
| raise HTTPException(status_code=410, detail="복구 세션이 만료되었습니다") | ||
|
|
||
|
|
@@ -638,7 +637,7 @@ def reset_password_via_recovery( | |
| raise HTTPException(status_code=403, detail="본인확인 검증이 완료되지 않았습니다") | ||
|
|
||
| reset_expires_at = session_state.get("reset_expires_at") | ||
| if not isinstance(reset_expires_at, datetime) or reset_expires_at <= datetime.utcnow(): | ||
| if not isinstance(reset_expires_at, datetime) or reset_expires_at <= datetime.now(timezone.utc): | ||
| _password_recovery_store.pop(session_token, None) | ||
| raise HTTPException(status_code=410, detail="재설정 토큰이 만료되었습니다") | ||
|
|
||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
issue (bug_risk): Creating the secret file with
O_EXCLafter an existence check introduces a race that now hard-fails startup.The new SECRET_KEY_FILE logic correctly fails on initialization errors, but the
exists()+os.open(..., O_EXCL)pattern is racy: if another process creates the file between these calls,os.openraisesFileExistsError, which the broadexceptcurrently turns into a fatalRuntimeErroreven though the file now exists and is usable.If multi-process startup or external creation of the secret is possible, handle
FileExistsErrorexplicitly (e.g., reopen the file read-only and use its contents) instead of treating it as a hard failure.