3. How does SSO Work?
Key Terms
Identity Provider (IdP)
- A service that handles authentication for users
- It is the central authority that verifies user credentials and issues tokens for accessing other applications.
- Examples:
- Microsoft Azure AD
- Okta
- Role in SSO:
- Validates user credentials (e.g., username and password).
- Issues authentication tokens (e.g., JWTs).
Service Provider (SP)
- The application or service that the user wants to access (e.g., a project management tool, HR system).
- Role in SSO:
- Delegates authentication to the IdP.
- Verifies tokens provided by the IdP to grant access.
JSON Web Token (JWT)
- A JSON Web Token (JWT) is a small, secure package of information used to prove someone is authenticated.
- Think of it like a digital ID card that you can show to different apps to prove who you are.
- Parts of a JWT
- A JWT has three parts, separated by dots (e.g.,
abc.def.ghi
): - Header:
- Contains basic information about the token, like the type of token (JWT) and how it’s secured (e.g., “signed with a secret”).
- Payload:
- Contains details about the user (called claims), such as:
- User ID
- Permissions (e.g., “admin” or “read-only”)
- Contains details about the user (called claims), such as:
- Signature:
- Ensures that the token hasn’t been tampered with.
- The server signs the token using a secret or private key, and the Service Provider checks this signature to confirm it’s valid.
- A JWT has three parts, separated by dots (e.g.,
- Why Use JWTs?
- Compact: Easy to send in a URL or request header.
- Secure: Can’t be modified without breaking the signature.
- Portable: Works across different applications and systems.
Analogy: A JWT as a Movie Ticket
- When you buy a movie ticket, the ticket has your seat and showtime written on it (this is like the payload).
- The theater’s stamp on the ticket ensures it’s genuine (this is the signature).
- You show the ticket to enter the theater.
- If you try to alter the ticket (e.g., changing the seat number), the stamp no longer matches, and you’re denied entry.
- JWTs work the same way—they securely store information about you and ensure that the information hasn’t been tampered with.
How SSO Works: Step-by-Step
User Tries to Access an Application
- The user attempts to log in to a Service Provider (SP), such as a project management tool.
Redirection to the IdP
- The Service Provider redirects the user to the Identity Provider (IdP) if they are not already authenticated.
User Authenticates with the IdP
- The user provides their credentials (e.g., username and password).
- The IdP validates the credentials.
IdP Issues a Token
- If authentication is successful, the IdP generates a token (e.g., a JWT) and sends it back to the Service Provider.
- The token contains information about the user, such as their ID and roles.
Service Provider Validates the Token
- The Service Provider verifies the token’s authenticity using the IdP’s public key.
- If valid, the user is granted access to the application.
Subsequent Access
- The token allows the user to access other connected Service Providers without needing to log in again.
Example: Corporate Application Suite
An employee logs in to their company’s IdP to access email, a project management tool, and a time tracker.
- The user logs in once via the IdP (e.g., Okta).
- The IdP issues a JWT to the email app, granting access.
- When the user visits the project management tool, it recognizes the JWT and automatically logs the user in.
- No additional login is needed for the time tracker or any other connected application.
Benefits of SSO
- Simplifies the user experience.
- Reduces password fatigue and enhances security.
- Centralizes authentication, making it easier to manage user access.