modify: 依赖更新
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
3.11
|
3.12
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ docker build -t chongming:latest .
|
|||||||
|
|
||||||
导出镜像
|
导出镜像
|
||||||
```shell
|
```shell
|
||||||
docker save -o chongming_v1.0.tar chongming:v1.0
|
docker save -o chongming_latest.tar chongming:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
导入镜像
|
导入镜像
|
||||||
```shell
|
```shell
|
||||||
docker load -i chongming_v1.0.tar
|
docker load -i chongming_latest.tar
|
||||||
```
|
```
|
||||||
|
|
||||||
运行镜像
|
运行镜像
|
||||||
@@ -80,5 +80,5 @@ mkdir -p /data/chongming
|
|||||||
docker run -d -p 8000:8000 \
|
docker run -d -p 8000:8000 \
|
||||||
-v /data/chongming/database.db:/app/database.db \
|
-v /data/chongming/database.db:/app/database.db \
|
||||||
-v /data/chongming/uploads:/app/uploads \
|
-v /data/chongming/uploads:/app/uploads \
|
||||||
--name chongming chongming:v1.0
|
--name chongming chongming:latest
|
||||||
```
|
```
|
||||||
|
|||||||
+4
-5
@@ -9,17 +9,16 @@ description = "基于 modules-bank 的 fastapi 打包脚手架"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aiofiles>=24.1.0",
|
"aiofiles",
|
||||||
"aiosqlite",
|
"aiosqlite",
|
||||||
"apscheduler",
|
"apscheduler",
|
||||||
"bcrypt==4.0.1",
|
"bcrypt",
|
||||||
"diskcache",
|
"diskcache",
|
||||||
"fastapi[uvicorn]",
|
"fastapi[uvicorn]",
|
||||||
"gunicorn>=23.0.0",
|
"gunicorn",
|
||||||
"module-bank",
|
"module-bank",
|
||||||
"passlib[bcrypt]",
|
|
||||||
"pyjwt",
|
"pyjwt",
|
||||||
"python-multipart>=0.0.20",
|
"python-multipart",
|
||||||
"sqlite-vfs",
|
"sqlite-vfs",
|
||||||
"sqlmodel[aiosqlite]",
|
"sqlmodel[aiosqlite]",
|
||||||
"tomli",
|
"tomli",
|
||||||
|
|||||||
+5
-3
@@ -1,12 +1,14 @@
|
|||||||
|
aiofiles
|
||||||
aiosqlite
|
aiosqlite
|
||||||
apscheduler
|
apscheduler
|
||||||
bcrypt==4.0.1
|
bcrypt
|
||||||
|
diskcache
|
||||||
fastapi[uvicorn]
|
fastapi[uvicorn]
|
||||||
|
gunicorn
|
||||||
module-bank
|
module-bank
|
||||||
passlib[bcrypt]
|
|
||||||
pyjwt
|
pyjwt
|
||||||
|
python-multipart
|
||||||
sqlite-vfs
|
sqlite-vfs
|
||||||
sqlitedict
|
|
||||||
sqlmodel[aiosqlite]
|
sqlmodel[aiosqlite]
|
||||||
tomli
|
tomli
|
||||||
typing-extensions
|
typing-extensions
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
from passlib.context import CryptContext
|
# src/chongming/app/core/security.py
|
||||||
|
import bcrypt
|
||||||
|
|
||||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
|
||||||
|
|
||||||
|
|
||||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
|
||||||
"""验证密码"""
|
|
||||||
return pwd_context.verify(plain_password, hashed_password)
|
|
||||||
|
|
||||||
|
|
||||||
def get_password_hash(password: str) -> str:
|
def get_password_hash(password: str) -> str:
|
||||||
"""密码哈希"""
|
salt = bcrypt.gensalt()
|
||||||
return pwd_context.hash(password)
|
hashed = bcrypt.hashpw(password.encode('utf-8'), salt)
|
||||||
|
return hashed.decode('utf-8')
|
||||||
|
|
||||||
|
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||||
|
return bcrypt.checkpw(
|
||||||
|
plain_password.encode('utf-8'),
|
||||||
|
hashed_password.encode('utf-8')
|
||||||
|
)
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from passlib.context import CryptContext
|
import bcrypt
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from ..model.user import User
|
from ..model.user import User
|
||||||
@@ -20,7 +20,6 @@ class AuthService:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.jwt_cache = get_jwt_cache()
|
self.jwt_cache = get_jwt_cache()
|
||||||
self.settings = get_config()
|
self.settings = get_config()
|
||||||
self.pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
|
||||||
|
|
||||||
async def authenticate_user(
|
async def authenticate_user(
|
||||||
self, email: str, password: str, session: AsyncSession
|
self, email: str, password: str, session: AsyncSession
|
||||||
@@ -29,7 +28,10 @@ class AuthService:
|
|||||||
user = await UserService.get_user_by_email(email, session)
|
user = await UserService.get_user_by_email(email, session)
|
||||||
if not user:
|
if not user:
|
||||||
return None
|
return None
|
||||||
if not self.pwd_context.verify(password, user.hashed_password):
|
if not bcrypt.checkpw(
|
||||||
|
password.encode('utf-8'),
|
||||||
|
user.hashed_password.encode('utf-8')
|
||||||
|
):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|||||||
Reference in New Issue
Block a user