SAML, OAuth 2.0, OpenID Connect (OIDC)

 

๐Ÿšช Quick Definitions

ProtocolWhat it DoesUsed For
SAMLAuthenticationWeb-based SSO (Single Sign-On)
OAuth 2.0Authorization (not authentication)Letting apps access resources on behalf of a user
OpenID Connect (OIDC)Authentication (built on OAuth 2.0)Logging users into apps securely

๐Ÿง  What Each One Is


๐Ÿ” SAML (Security Assertion Markup Language)

  • Old but gold — XML-based standard.

  • Used for authentication (NOT authorization).

  • Popular for SSO in enterprise environments (e.g., login to Salesforce, Google Workspace, etc.).

  • Works with browsers and web apps.

๐Ÿ” Flow Summary:

  1. User tries to access an app (called Service Provider).

  2. App redirects user to Identity Provider (IdP) (like Azure AD, Okta).

  3. User logs in.

  4. IdP sends back a SAML assertion (XML) to the app.

  5. App verifies the assertion → user gets access.

✅ Common Use Case:

  • Enterprise SSO: "Log in to Workday using your company credentials."


๐Ÿ”‘ OAuth 2.0

  • framework for authorization.

  • Doesn't deal with identity directly (so it doesn’t log users in).

  • It lets apps access data on behalf of a user, without sharing the user’s password.

๐Ÿ” Flow Summary:

  1. User logs into App A.

  2. App A asks App B (like Google or Microsoft): "Can I access this user’s calendar?"

  3. User is redirected to App B to approve access.

  4. App B gives App A a token to access calendar data.

✅ Common Use Case:

  • Giving a third-party app permission to access your Google DriveMicrosoft Graph, or GitHub repo.


๐Ÿงพ OpenID Connect (OIDC)

  • An identity layer built on top of OAuth 2.0.

  • Adds authentication to OAuth.

  • Returns an ID token (JWT) that confirms who the user is.

  • Supports mobile appsweb appsAPIs, and SPAs (single-page apps).

๐Ÿ” Flow Summary:

  1. User logs into an app.

  2. App redirects to an Identity Provider (IdP) like Microsoft, Google, or Auth0.

  3. User authenticates.

  4. IdP sends back:

    • ID token → proves user’s identity

    • Access token → lets app access user data (optional)

✅ Common Use Case:

  • Logging into a mobile app using "Sign in with Google" or Microsoft.


๐Ÿ” Key Differences

FeatureSAMLOAuth 2.0OpenID Connect (OIDC)
PurposeAuthenticationAuthorizationAuthentication + Authorization
Standard FormatXMLJSON (tokens)JSON (JWTs)
Main Use CaseSSO for enterprise web appsDelegated access to APIsUser login (web, mobile, APIs)
Mobile Friendly❌ Not ideal✅ Yes✅ Yes
Token TypeSAML Assertion (XML)Access TokenID Token (JWT) + Access Token
Password Shared?NoNoNo
Built OnN/AN/ABuilt on top of OAuth 2.0

๐ŸŽฏ When to Use What?

ScenarioBest Protocol
SSO for enterprise web appsSAML
Letting a 3rd party app access user data (e.g., calendar, files)OAuth 2.0
Logging users into a web/mobile app using Google/MicrosoftOpenID Connect

๐Ÿงช Real-Life Example:

Imagine you're building a mobile app that lets users view their Outlook calendar.

  • Use OpenID Connect to authenticate the user.

  • Use OAuth 2.0 to get a token that allows you to access their calendar data via Microsoft Graph API.

Popular posts from this blog

Autodiscover

Azure Active Directory (Azure AD)

Active Directory (AD)