switch·Esc back

Authentication

You might say

How do I verify that someone is who they say they are? I need to add sign-in.

Verify who is making the requestAuthentication proves an identity through a password, passkey, one-time code, or trusted provider and then maintains a session. Store credentials safely, limit repeated attempts, and protect recovery paths. After identity is known, authorization still decides what that person may do.

When to use it

  • Sign a user in
  • Maintain a secure session
  • Verify a sensitive action again
  • Recover account access through a controlled process

When NOT to use it

  • Store plain-text passwords
  • Treat a user ID sent by the browser as proof of identity
  • Use long-lived tokens with no revocation plan
  • Reveal whether a private account exists through detailed errors
Anatomy
Identity credentialsServer verificationLogin status
Password, one-time verification code or identity result returned by third-party platform
The server checks the credentials, speed limit and handles the failure. It does not believe that the front end announces that the login is successful.
Use secure cookies or protected tokens to allow subsequent requests to prove it is the same user
Variants
Cookie Session
Set-Cookie: session=…
Common for web apps; browsers send the cookie automatically.
Bearer Token
Authorization: Bearer …
Common for mobile apps and standalone APIs.
OAuth Login
Continue with GitHub
Delegate identity proof to a trusted provider.
Typical use cases
Sign in
Email passwordEstablish login status after successful verification
Login
Session✓ Established
Passkey
One-time verification codeThe verification code is only valid for a short period of time
Remaining time04:32Number of attempts1 / 5
Verification
One-time code
Third-party loginLeave identity verification to a mature platform
Continue using GitHubContinue using Google
The platform returns the identity result, and this site then creates its own session
Account recovery
Exit and expirationRe-authentication is required after the session expires
Click to exitServer-side revoke SessionProtected request → 401
Further reading