{"id":965,"date":"2025-09-16T07:27:02","date_gmt":"2025-09-16T07:27:02","guid":{"rendered":"https:\/\/www.rajeshkumar.xyz\/blog\/?p=965"},"modified":"2025-09-16T07:30:48","modified_gmt":"2025-09-16T07:30:48","slug":"identity-oauth2-oidc-and-beyond-a-developers-handbook","status":"publish","type":"post","link":"https:\/\/www.rajeshkumar.xyz\/blog\/identity-oauth2-oidc-and-beyond-a-developers-handbook\/","title":{"rendered":"Identity, OAuth2, OIDC, and Beyond: A Developer\u2019s Handbook"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"615\" src=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1-1024x615.png\" alt=\"\" class=\"wp-image-969\" srcset=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1-1024x615.png 1024w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1-300x180.png 300w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1-768x462.png 768w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1-1536x923.png 1536w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"617\" src=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1024x617.png\" alt=\"\" class=\"wp-image-967\" srcset=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-1024x617.png 1024w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-300x181.png 300w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-768x463.png 768w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image.png 1224w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Tutorial: The Complete Guide to Modern Identity and Access Management<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1. <strong>Identity \u2014 the \u201cWho\u201d<\/strong><\/h2>\n\n\n\n<p>Identity is the digital representation of a person, service, or device.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: \u201cRajesh with email <code>rajesh@example.com<\/code> and employee ID <code>1234<\/code>.\u201d<\/li>\n\n\n\n<li><strong>Why it matters<\/strong>: Every other IAM concept builds on knowing <em>who<\/em> is accessing resources.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. <strong>Authentication \u2014 Prove the Who<\/strong><\/h2>\n\n\n\n<p>Authentication verifies identity.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Methods<\/strong>: Passwords, OTP, biometrics, WebAuthn\/Passkeys.<\/li>\n\n\n\n<li><strong>Example<\/strong>: Logging into Gmail using a password + OTP.<\/li>\n\n\n\n<li><strong>Best Practice<\/strong>: Use <strong>MFA<\/strong> (multi-factor authentication) for higher security.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"865\" src=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-2-1024x865.png\" alt=\"\" class=\"wp-image-970\" srcset=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-2-1024x865.png 1024w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-2-300x254.png 300w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-2-768x649.png 768w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-2-1536x1298.png 1536w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2025\/09\/image-2.png 2014w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">3. <strong>Authorization \u2014 What They Can Do<\/strong><\/h2>\n\n\n\n<p>Authorization determines <strong>permissions after login<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Models<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>RBAC<\/strong> (Role-based): Admin, User, Guest.<\/li>\n\n\n\n<li><strong>ABAC<\/strong> (Attribute-based): Department = HR, Location = Tokyo.<\/li>\n\n\n\n<li><strong>PBAC<\/strong> (Policy-based): If <code>role=Manager<\/code> and <code>location=HQ<\/code>, then allow.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Example<\/strong>: A doctor can view patient records; a receptionist can only schedule appointments.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. <strong>OAuth 2.0 \u2014 Delegated Authorization Framework<\/strong><\/h2>\n\n\n\n<p>OAuth2 lets apps access resources on a user\u2019s behalf.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tokens<\/strong>: Access Token, Refresh Token.<\/li>\n\n\n\n<li><strong>Example<\/strong>: Canva asks permission to access your Google Drive photos. You approve \u2192 Canva gets an <strong>access token<\/strong>.<\/li>\n\n\n\n<li><strong>Note<\/strong>: OAuth2 \u2260 Authentication. It\u2019s mainly about <strong>authorization<\/strong>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5. <strong>OIDC (OpenID Connect) \u2014 Authentication on Top of OAuth2<\/strong><\/h2>\n\n\n\n<p>OIDC extends OAuth2 to handle <strong>authentication + identity<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tokens<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>ID Token<\/strong> \u2192 JWT containing user info.<\/li>\n\n\n\n<li><strong>Access Token<\/strong> \u2192 permissions for APIs.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Example<\/strong>: \u201cSign in with Google\u201d \u2192 OIDC gives the website Rajesh\u2019s identity (email, name).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">6. <strong>Tokens \u2014 The Currency of Access<\/strong><\/h2>\n\n\n\n<p>Tokens are proof of identity and permissions.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Types<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Access Token \u2192 access APIs.<\/li>\n\n\n\n<li>Refresh Token \u2192 get new tokens.<\/li>\n\n\n\n<li>ID Token \u2192 prove who the user is.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Example<\/strong>: Access Token lets Slack read your calendar data after you log in via Google.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">7. <strong>JWT (JSON Web Token)<\/strong><\/h2>\n\n\n\n<p>JWT is the format most tokens use.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Structure<\/strong>: <code>Header.Payload.Signature<\/code>.<\/li>\n\n\n\n<li><strong>Claims<\/strong> inside = user info, expiry, roles.<\/li>\n\n\n\n<li><strong>Example<\/strong>: <code>{ \"sub\": \"1234567890\", \"name\": \"Rajesh\", \"role\": \"Admin\", \"exp\": 1712345678 }<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">8. <strong>Claims \u2014 Identity Details in Tokens<\/strong><\/h2>\n\n\n\n<p>Claims are facts about the user\/system embedded in tokens.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: <code>sub=1234<\/code>, <code>email=rajesh@example.com<\/code>, <code>role=Admin<\/code>.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: APIs read claims to enforce role-based authorization.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">9. <strong>Identity Providers (IdP)<\/strong><\/h2>\n\n\n\n<p>IdPs authenticate users and issue tokens.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Examples<\/strong>: Google, Azure AD, Okta, Auth0, Keycloak.<\/li>\n\n\n\n<li><strong>Role<\/strong>: Trusted source of authentication.<\/li>\n\n\n\n<li><strong>Example<\/strong>: You log in to Zoom with Google \u2014 Google is the IdP.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">10. <strong>IdentityServer<\/strong><\/h2>\n\n\n\n<p>An <strong>IdP implementation for .NET<\/strong> apps.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: A company builds its own login system using IdentityServer instead of outsourcing to Google or Okta.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">11. <strong>SSO (Single Sign-On)<\/strong><\/h2>\n\n\n\n<p>Login once \u2192 access multiple apps.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: Logging into Google once gives you access to Gmail, Drive, YouTube.<\/li>\n\n\n\n<li><strong>Enabled by<\/strong>: OIDC, tokens, centralized IdPs.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">12. <strong>Federation \u2014 Trust Across Domains<\/strong><\/h2>\n\n\n\n<p>Federation lets one identity system trust another.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Standards<\/strong>: OIDC (modern), SAML (legacy, XML-based).<\/li>\n\n\n\n<li><strong>Example<\/strong>: Spotify lets you log in with Facebook \u2192 Facebook acts as the trusted IdP.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">13. <strong>SCIM (System for Cross-domain Identity Management)<\/strong><\/h2>\n\n\n\n<p>Handles <strong>user provisioning and de-provisioning<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: When a new employee joins, SCIM auto-creates accounts in Slack, GitHub, Google Workspace.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">14. <strong>PKCE &amp; Session Management \u2014 Extra Security Layers<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PKCE<\/strong>: Secures OAuth2 flows in mobile\/web apps.<\/li>\n\n\n\n<li><strong>Session Management<\/strong>: Handles login state, re-authentication, and global logout.<\/li>\n\n\n\n<li><strong>Example<\/strong>: Revoking your Google session logs you out of all Google apps.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">15. <strong>Consent &amp; Scopes \u2014 Granular Access Rights<\/strong><\/h2>\n\n\n\n<p>Scopes define what an app can do.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>calendar.read<\/code> \u2192 read-only calendar.<\/li>\n\n\n\n<li><code>calendar.write<\/code> \u2192 modify calendar.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Consent screen<\/strong>: User approves scopes during OAuth2 login.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">16. <strong>Introspection &amp; Revocation<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Introspection endpoint<\/strong> \u2192 APIs check if a token is still valid.<\/li>\n\n\n\n<li><strong>Revocation endpoint<\/strong> \u2192 Users or admins revoke access.<\/li>\n\n\n\n<li><strong>Example<\/strong>: You revoke Canva\u2019s access to Google Drive \u2192 Canva\u2019s tokens are invalidated.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">17. <strong>API Gateway \/ Policy Enforcement<\/strong><\/h2>\n\n\n\n<p>API gateways enforce <strong>token validation, scopes, and claims<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Examples<\/strong>: Kong, Apigee, AWS API Gateway, Envoy.<\/li>\n\n\n\n<li><strong>Example<\/strong>: An API gateway checks if Rajesh\u2019s access token includes <code>role=Admin<\/code> before allowing an update.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">18. <strong>Zero Trust \u2014 Continuous Authorization<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Principle<\/strong>: \u201cNever trust, always verify.\u201d<\/li>\n\n\n\n<li>Access is continuously re-validated based on identity, device, location, risk.<\/li>\n\n\n\n<li><strong>Example<\/strong>: Even after login, your bank re-checks identity if you try a large transfer.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 Summary in One Line<\/h1>\n\n\n\n<p><strong>Identity \u2192 Authentication \u2192 Authorization \u2192 OAuth2 \u2192 OIDC \u2192 Tokens (JWT, claims) \u2192 IdPs (Google, IdentityServer) \u2192 SSO\/Federation \u2192 SCIM \u2192 PKCE &amp; Sessions \u2192 Scopes\/Consent \u2192 Introspection \u2192 API Gateways \u2192 Zero Trust<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tutorial: The Complete Guide to Modern Identity and Access Management 1. Identity \u2014 the \u201cWho\u201d Identity is the digital representation [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-965","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/comments?post=965"}],"version-history":[{"count":2,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/965\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/965\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/media?parent=965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/categories?post=965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/tags?post=965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}