Update 2025-12-14 13:17:54
Some checks failed
Deploy VConnect API / Test Build (push) Successful in 23s
Deploy VConnect API / Deploy to Server (push) Failing after 9s

This commit is contained in:
unknown
2025-12-14 13:17:54 +09:00
parent 00893d9aa6
commit 513ff991eb
2 changed files with 21 additions and 6 deletions

View File

@@ -1,12 +1,26 @@
from passlib.context import CryptContext
import bcrypt
# bcrypt 컨텍스트
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
# bcrypt 컨텍스트 제거 (직접 사용)
def hash_password(password: str) -> str:
"""비밀번호 해시화"""
return pwd_context.hash(password)
# bcrypt는 bytes를 처리하므로 인코딩 필요
pwd_bytes = password.encode('utf-8')
salt = bcrypt.gensalt()
hashed = bcrypt.hashpw(pwd_bytes, salt)
return hashed.decode('utf-8')
def verify_password(plain_password: str, hashed_password: str) -> bool:
"""비밀번호 검증"""
return pwd_context.verify(plain_password, hashed_password)
try:
if not plain_password or not hashed_password:
return False
pwd_bytes = plain_password.encode('utf-8')
# DB에 저장된 해시는 str일 수 있으므로 인코딩
hashed_bytes = hashed_password.encode('utf-8')
return bcrypt.checkpw(pwd_bytes, hashed_bytes)
except Exception:
# 형식 오류 등 발생 시 인증 실패 처리
return False

View File

@@ -10,7 +10,8 @@ alembic==1.13.1
# Authentication & Security
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4
# passlib dependency removed
bcrypt>=4.0.1
python-dotenv==1.0.0
pydantic-settings==2.1.0
email-validator>=2.0.0