Skip to content

Commit ad6f72a

Browse files
committed
fix: 비밀번호 해싱 시 bcrypt 직접 사용
pyca/bcrypt#684
1 parent 6cf4816 commit ad6f72a

File tree

3 files changed

+12
-35
lines changed

3 files changed

+12
-35
lines changed

projects/geugeu/app/core/security.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
from datetime import UTC, datetime, timedelta
22
from typing import Any
33

4+
import bcrypt
45
import jwt
5-
from passlib.context import CryptContext
66

77
from app.core.config import settings
88

9-
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
10-
11-
129
ALGORITHM = "HS256"
1310

1411

@@ -20,8 +17,14 @@ def create_access_token(subject: str | Any, expires_delta: timedelta) -> str:
2017

2118

2219
def verify_password(plain_password: str, hashed_password: str) -> bool:
23-
return pwd_context.verify(plain_password, hashed_password)
20+
return bcrypt.checkpw(
21+
password=plain_password.encode(),
22+
hashed_password=hashed_password.encode(),
23+
)
2424

2525

2626
def get_password_hash(password: str) -> str:
27-
return pwd_context.hash(password)
27+
return bcrypt.hashpw(
28+
password=password.encode(),
29+
salt=bcrypt.gensalt(),
30+
).decode()

projects/geugeu/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
88
"alembic>=1.15.2",
9+
"bcrypt>=4.3.0",
910
"fastapi[standard]>=0.115.12",
1011
"nanoid>=2.0.0",
11-
"passlib[bcrypt]>=1.7.4",
1212
"psycopg2-binary>=2.9.10",
1313
"pydantic-settings>=2.9.1",
1414
"pyjwt>=2.10.1",
@@ -23,5 +23,4 @@ dev = [
2323
"ruff>=0.11.7",
2424
"testcontainers>=4.10.0",
2525
"types-nanoid>=2.0.0.20240601",
26-
"types-passlib>=1.7.7.20250408",
2726
]

projects/geugeu/uv.lock

Lines changed: 2 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)