Authentication
Аутентификация
The process of checking that a user, device, or service is who it claims to be. When you sign in with a passkey, for example, the site verifies that you control the passkey linked to your account.
What authentication proves
Typing an email address into a sign-in form tells the website which account you claim to control. That is identification, not proof. A password check or a successful passkey challenge provides evidence that you control a credential registered to that account. It does not necessarily tell the site who you are in the real world.
Authentication and authorization answer different questions. A support agent can sign in successfully but still be denied access to payroll records. The sign-in establishes which account is making the request; the permission check decides whether that account can read the records.
From sign-in to the next request
Suppose you sign in to an issue tracker with a password. The browser submits it over HTTPS, and the server verifies it against the account's stored password hash. The server should use a password hashing algorithm such as Argon2id with a random salt for each password, not store plaintext or use reversible encryption. The salt means two people with the same password don't get the same stored hash.
After sign-in, the server can create a session and send the browser a cookie containing a random session ID. On a later request, the browser sends the cookie and the server looks up the session, checks that it is still valid, and identifies the account. The password does not have to travel with every request. In a token-based design, a service may instead validate a signed token intended for that service and then make a separate permission check.
Where the proof comes from
Authentication factors fall into three families: something you know, such as a password; something you have, such as a security key; and something you are, such as a fingerprint. Two-factor authentication requires two different types of factors. A password followed by a PIN adds another step, but both are knowledge factors. Authentication also applies to software: two services can use mutual TLS to authenticate each other with certificates.
What interviewers listen for
When asked to compare cookies and JWTs, first separate how a credential travels from what it contains. A cookie can carry an opaque session ID or a JWT. A JWT is a token format, and decoding a signed JWT gives you its contents, not proof that they're trustworthy. The receiving service must verify the signature and check claims such as the expected issuer, audience, and expiration.
Another common question is whether OAuth 2.0 is a login protocol. OAuth 2.0 lets a client obtain limited access to a resource, such as permission to read a calendar. OpenID Connect builds on it for sign-in: it gives the application an ID token that it validates to learn which user signed in.