Escribe para buscar…

Security

FastAPI provides several tools to help you deal with Security easily, rapidly, in a standard way, without having to study and learn all the security specifications.

Esta página todavía no se ha traducido — se muestra en su idioma original:English

Introducció

Hash password

Argon2 is a modern, secure password hashing algorithm and winner of the 2015 Password Hashing Competition. It’s memory-hard and resists brute-force, side-channel, and precomputation attacks, making it the top choice for securing passwords in modern systems.

ps
uv add argon2-cffi
python
from argon2 import PasswordHasher
ph = PasswordHasher()
res = ph.hash("MySecurePassword")
print(res)

To check whether a user-entered password matches the stored hash:

python
from argon2 import PasswordHasher
ph = PasswordHasher()
res = ph.hash("MySecurePassword")
try:
    ph.verify(res, "MySecurePassword")
    print("Password match!")
except Exception:
    print("Incorrect password.")

Bearer authentication

Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the Authorization header when making requests to protected resources:

Authorization: Bearer <token>

Estás leyendo una vista previa.

Inicia sesión con Google para leer la página completa. Una cuenta de Google incluye 5 páginas gratuitas en total; el alumnado y el profesorado leen las páginas de su curso sin límite.

Iniciar sesión