Skip to content
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

Remove passlib #1220

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions backend/app/app/api/utils.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import bcrypt
from aiofiles.threadpool.binary import AsyncBufferedIOBase
from fastapi import UploadFile
from passlib.context import CryptContext

from app.core.constants import BLOCKSIZE

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")


# See https://github.com/fastapi/fastapi/discussions/11773#discussioncomment-10640267
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return bcrypt.checkpw(
bytes(plain_password, encoding="utf-8"),
bytes(hashed_password, encoding="utf-8"),
)


def get_password_hash(password):
return pwd_context.hash(password)
return bcrypt.hashpw(
bytes(password, encoding="utf-8"),
bcrypt.gensalt(),
)


async def upload_to_file(upload: UploadFile, fp: AsyncBufferedIOBase):
Expand Down
3 changes: 0 additions & 3 deletions backend/app/app/core/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
from fastapi.staticfiles import StaticFiles
import jwt
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext

from app.api.deps import oauth2_scheme
from app.core.config import settings
from app.core.logging import logger

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")


ALGORITHM = "HS256"

Expand Down
2 changes: 1 addition & 1 deletion backend/app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uvicorn[standard]
fastapi
python-multipart
pyjwt[crypto]
passlib[bcrypt]
bcrypt
sqlalchemy
pydantic[dotenv]
psycopg2
Expand Down
Loading