Browse Source

replace `passlib` to `pwdlib`

pull/13917/head
Neizvestnyj 1 week ago
parent
commit
071d904388
  1. 8
      docs_src/security/tutorial004.py
  2. 8
      docs_src/security/tutorial004_an.py
  3. 8
      docs_src/security/tutorial004_an_py39.py
  4. 8
      docs_src/security/tutorial004_py310.py
  5. 8
      docs_src/security/tutorial005.py
  6. 8
      docs_src/security/tutorial005_an.py
  7. 8
      docs_src/security/tutorial005_an_py310.py
  8. 8
      docs_src/security/tutorial005_an_py39.py
  9. 8
      docs_src/security/tutorial005_py310.py
  10. 8
      docs_src/security/tutorial005_py39.py

8
docs_src/security/tutorial004.py

@ -5,7 +5,7 @@ import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel
# to get a string like this run:
@ -46,7 +46,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@ -54,11 +54,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial004_an.py

@ -5,7 +5,7 @@ import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel
from typing_extensions import Annotated
@ -47,7 +47,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@ -55,11 +55,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial004_an_py39.py

@ -5,7 +5,7 @@ import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel
# to get a string like this run:
@ -46,7 +46,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@ -54,11 +54,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial004_py310.py

@ -4,7 +4,7 @@ import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel
# to get a string like this run:
@ -45,7 +45,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@ -53,11 +53,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial005.py

@ -9,7 +9,7 @@ from fastapi.security import (
SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError
# to get a string like this run:
@ -58,7 +58,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(
tokenUrl="token",
@ -69,11 +69,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial005_an.py

@ -9,7 +9,7 @@ from fastapi.security import (
SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError
from typing_extensions import Annotated
@ -59,7 +59,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(
tokenUrl="token",
@ -70,11 +70,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial005_an_py310.py

@ -9,7 +9,7 @@ from fastapi.security import (
SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError
# to get a string like this run:
@ -58,7 +58,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(
tokenUrl="token",
@ -69,11 +69,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial005_an_py39.py

@ -9,7 +9,7 @@ from fastapi.security import (
SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError
# to get a string like this run:
@ -58,7 +58,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(
tokenUrl="token",
@ -69,11 +69,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial005_py310.py

@ -8,7 +8,7 @@ from fastapi.security import (
SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError
# to get a string like this run:
@ -57,7 +57,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(
tokenUrl="token",
@ -68,11 +68,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

8
docs_src/security/tutorial005_py39.py

@ -9,7 +9,7 @@ from fastapi.security import (
SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from passlib.context import CryptContext
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError
# to get a string like this run:
@ -58,7 +58,7 @@ class UserInDB(User):
hashed_password: str
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(
tokenUrl="token",
@ -69,11 +69,11 @@ app = FastAPI()
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
return password_hash.hash(password)
def get_user(db, username: str):

Loading…
Cancel
Save