रिसोर्स · 43

OAuth और OpenID कनेक्ट: इंटीग्रेशन को एंड टू एंड वेरिफ़ाई करें

साइन-इन, डेलिगेशन और डेटा परमिशन को अलग करें, फिर रीडायरेक्ट, टोकन, सेशन और रिवोकेशन को टेस्ट करें।

अपडेटेड · 13 min

काल्पनिक खाली पहचान सत्यापन कक्ष: दो सुरक्षा कुंजियाँ, खाली कार्ड और बरगंडी फ़ोल्डर AI से निर्मित संपादकीय चित्रण

यह गाइड क्या पाने में मदद करती है

  • आइडेंटिटी को ऑथराइजेशन से अलग करें
  • अनचाहे रीडायरेक्ट और टोकन को रिजेक्ट करें
  • रिजेक्शन को भी सक्सेस की तरह सावधानी से टेस्ट करें
  • जाने या इंसिडेंट के बाद एक्सेस हटाने को वेरिफाई करें

जल्दी से चेक करें

  • किस प्रोवाइडर और इश्यूअर से उम्मीद की जाती है?
  • क्या रीडायरेक्ट URI ठीक से रजिस्टर्ड है?
  • क्या कोई ID टोकन गलत तरीके से एक्सेस टोकन के तौर पर इस्तेमाल किया जा रहा है?
  • क्या हर रिसोर्स ओनरशिप चेक करता है?
  • कौन सा एक्सेस रद्द होने के बाद भी बचता है?

स्टेप-बाय-स्टेप तरीका

  1. 1

    डिप्लॉय किया गया फ्लो बनाएं

    पब्लिक या कॉन्फिडेंशियल क्लाइंट, ब्राउज़र, ऑथराइजेशन सर्वर, API और OIDC प्रोवाइडर की पहचान करें। रिकॉर्ड करें कि कोड और टोकन कहां ट्रैवल करते हैं, उन्हें कौन स्टोर करता है और कौन से रोल दिए गए हैं। सेल्स डायग्राम से असली डिप्लॉयमेंट तय नहीं होता।

    डिलीवरेबल: फ्लो, ट्रस्ट बाउंड्री और कंपोनेंट ओनर।

  2. 2

    साइन-इन ट्रांज़ैक्शन चेक करें

    क्लाइंट के लिए सही PKCE के साथ कोड फ्लो का इस्तेमाल करें। S256, ट्रांज़ैक्शन बाइंडिंग, रजिस्टर्ड रीडायरेक्ट और जाली रिक्वेस्ट से सुरक्षा चेक करें। एक अनएक्सपेक्टेड URI, गलत वेरिफायर, रिप्ले किया गया कोड और अनएक्सपेक्टेड इश्यूअर को टेस्ट करें। RFC 9700 क्लाइंट टाइप के हिसाब से ज़रूरतों और सुझावों को अलग करता है।

    डिलीवरेबल: अलाउड और डिनाइड टेस्ट रिजल्ट।

  3. 3

    सही टोकन वैलिडेट करें

    API अपने एक्सेस टोकन को फॉर्मेट और प्रोवाइडर नियमों के हिसाब से वैलिडेट करता है: सिग्नेचर या इंट्रोस्पेक्शन, इश्यूअर, ऑडियंस, एक्सपायरी और परमिशन। OIDC क्लाइंट अलग से आइडेंटिटी टोकन को वैलिडेट करता है। एक वैलिड सिग्नेचर यह तय नहीं करता कि टोकन इसी API का है।

    डिलीवरेबल: वैलिडेशन कॉन्ट्रैक्ट और ऑडियंस और एक्सपायरी टेस्ट।

  4. 4

    बिज़नेस परमिशन चेक करें

    किसी दूसरे अकाउंट के ओनरशिप वाले ऑब्जेक्ट, लोअर रोल, प्राइवेट फ़ील्ड और एडमिनिस्ट्रेटिव ऑपरेशन को टेस्ट करें। कोई स्कोप या ऑथेंटिकेटेड गेटवे, रिक्वेस्ट किए गए रिसोर्स पर सर्वर-साइड चेक की जगह नहीं लेता है। ऑथराइज़्ड टेस्ट अकाउंट और डेटा का इस्तेमाल करें।

    डिलीवरेबल: रोल, ऑब्जेक्ट, ऑपरेशन और एक्सपेक्टेड-डिनायल मैट्रिक्स।

  5. 5

    एक्सपायरी और रिवोकेशन करें

    लोकल सेशन, प्रोवाइडर सेशन, एक्सेस टोकन और रिफ्रेश टोकन को अलग करें। डिपार्चर, खोया हुआ डिवाइस, रोल चेंज, साइनिंग-की रोटेशन और प्रोवाइडर आउटेज को टेस्ट करें। यह मानने के बजाय कि साइन-आउट तुरंत सब कुछ रिवोक कर देता है, बचे हुए एक्सेस टाइम को डॉक्यूमेंट करें।

    डिलीवरेबल: एक्सेस-रिमूवल टाइमलाइन और एक्सेप्शन।

  6. 6

    सीक्रेट्स को एक्सपोज़ किए बिना ऑब्ज़र्व करें

    ट्रांज़ैक्शन रेफरेंस, वैलिडेशन डिसीज़न, एरर कैटेगरी और कॉन्फ़िगरेशन वर्शन लॉग करें। कोड, टोकन और सीक्रेट्स को एक्सक्लूड करें। डायग्नोसिस, इंटीग्रेशन शटडाउन और वैलिडेट किए गए कॉन्फ़िगरेशन पर रोलबैक तैयार करें; प्रोवाइडर चेंज के बाद टेस्ट दोबारा चलाएं।

    डिलीवरेबल: ऑपरेटिंग प्रोसीजर और रिग्रेशन चेक।

काल्पनिक काम का उदाहरण

उदाहरण वाली स्थिति

उदाहरण के लिए: दो क्लाइंट एक आइडेंटिटी प्रोवाइडर का इस्तेमाल करते हैं। पहले के लिए वैलिड टोकन दूसरे क्लाइंट के API को दिखाया जाता है।

फैसला और उम्मीद का सबूत

API गलत ऑडियंस को रिजेक्ट कर देता है, टोकन-फ़्री ट्रेस रिकॉर्ड करता है और कोई डेटा रिटर्न नहीं करता है। डिनायल एक रिग्रेशन टेस्ट बन जाता है।

मैकेनिज़्म में अंतर बताएं

मैकेनिज़्ममकसदवेरिफ़िकेशन या लिमिटेशन
OAuth 2.0रिसोर्स एक्सेस देंसर्वर-साइड ऑब्जेक्ट परमिशन
OpenID कनेक्टवैलिडेटेड ID टोकन के ज़रिए पहचान बनानाजारी करने वाला, ऑडियंस और ट्रांज़ैक्शन वैलिडेशन
एप्लीकेशन सेशनएप्लीकेशन साइन-इन बनाए रखनाएक्सपायरी, इनवैलिडेशन और सेशन प्रोटेक्शन

मैनेजमेंट इंडिकेटर

इंडिकेटरयह क्या मापता हैपहला एक्शन
डिनायल ठीक करनामना किए गए केस असल में ब्लॉक करनाहर अचानक एक्सेप्टेंस को ठीक करना
रिवोकेशन में देरीज़रूरी एक्सेस गायब होने तक का समयसेशन और टोकन अलग-अलग चेक करना
वैलिडेशन फेलियरकारण और वर्शन के हिसाब से रिजेक्शनकॉन्फ़िगरेशन एरर से अटैक को अलग करना

आम गलतियाँ

  • ऑथेंटिकेशन को ऑथराइज़ेशन से कन्फ्यूज़ करना
  • सिग्नेचर चेक करने के बाद किसी भी ऑडियंस को एक्सेप्ट करना
  • ब्रॉड रीडायरेक्ट रजिस्टर करना URIs
  • आसान डीबगिंग के लिए टोकन लॉग करना

अक्सर पूछे जाने वाले सवाल

क्या PKCE हर कंट्रोल को रिप्लेस करता है?

नहीं। यह तय फ्लो में कोड एक्सचेंज को प्रोटेक्ट करता है; टोकन वैलिडेशन, रीडायरेक्ट, बिज़नेस ऑथराइज़ेशन और सेशन को अभी भी चेक करने की ज़रूरत है।

क्या JWT एक परमिशन है?

JWT एक फ़ॉर्मेट है। क्लेम सिर्फ़ वैलिडेशन और आपके API रूल्स के एप्लिकेशन के बाद ही इस्तेमाल करने लायक बनते हैं।

क्या वैलिडेशन शुरू से बनाना चाहिए?

एक मेंटेन की गई लाइब्रेरी और प्रोवाइडर डॉक्यूमेंटेशन को प्राथमिकता दें, फिर अपने कॉन्फ़िगरेशन को टेस्ट करें। एक सही लाइब्रेरी को भी गलत तरीके से कॉन्फ़िगर किया जा सकता है।

उपयोगी सत्यापन के लिए कौन-सा प्रमाण रखें?

खाते का संदर्भ, भूमिकाएँ, संसाधन और API उत्तर रखें। सफल लॉगिन हर संसाधन के सही अधिकार सिद्ध नहीं करता; सत्र के रहस्य दर्ज न करें।

OAuth/OIDC: लक्ष्य और अधिकार

इस संस्करण में विस्तृत संदर्भ टिप्पणियाँ अंग्रेज़ी में उपलब्ध हैं।

Which token belongs to which recipient? A testable validation contract

A secure OAuth/OIDC integration connects each token to its purpose, issuer and intended recipient. An ID token tells the OIDC client about authentication; an access token is presented to a protected resource. Successful sign-in alone does not authorise a read, a change or an AI agent’s tool call.

This reference covers a specific profile: an API consuming JWT access tokens under RFC 9068. OAuth 2.0 does not require every access token to use JWT. Clients must treat their access tokens as opaque; the resource server owns the validation contract. The examples below are fictional, with no secret or usable signature.

Where codes and tokens belong
Where codes and tokens belong Four independent rows show the recipients: code to token endpoint, ID token to OIDC client, access token to API, refresh token to token endpoint. This is not the full exchange sequence. Code → Token endpoint Transaction-bound exchange ID token → OIDC client Identity and client_id audience Access token → API / resource Check audience and permissions Refresh token → Token endpoint Renewal, not an API call Distinct destinations · conceptual map, not a network sequence

Four objects with distinct purposes

Four objects with distinct purposes
ObjectRecipient and purposeBoundary to retain
Authorisation codeAuthorisation server token endpoint: redeem the code within the intended transaction.The code is not an API permission; check binding to the client, redirect and PKCE.
ID tokenOIDC client: validate identity and transaction; aud contains its client_id.Do not reuse it as an API access credential; apply the OIDC rules for the relevant flow.
Access tokenResource server: access within the grant; its audience identifies the intended resource.Validate the token, then operation and object permissions. The client must not depend on its internal content.
Refresh tokenAuthorisation server token endpoint: obtain new access tokens.Do not send it to the resource server; its lifecycle differs from the local session.

Eight controls for the validation contract

Eight controls for the validation contract
ControlRule and scopeEvidence without tokens
Profile and typFor RFC 9068, check typ = at+jwt or application/at+jwt. Other profiles need their own rules; “any signed JWT” is too broad a contract.Configured profile and a rejected ID/access token confusion case.
Algorithm and keysVerify the signature with the expected issuer’s keys and algorithms allowed by configuration. RFC 9068 excludes alg = none; a received value does not set policy by itself.Cryptographic policy version and result, with no secret material.
Issuer issCompare exactly with the expected issuer. A similar host, path or suffix does not establish trust.Configuration reference and issuer_mismatch reason.
Audience audThe expected recipient must appear in aud. An audience array is possible; finding the recipient does not replace other checks.Expected resource and a test using a token intended for another API.
Expiry expCurrent time must precede exp; any small clock leeway is an explicit policy. The teaching fixture uses zero seconds of leeway.Test clock, configured leeway and an exercised expiry boundary.
Scopes and objectBind each scope to the resource and operation. Then check ownership, tenant and business policy on the server. RFC 9068 does not define all this authorisation.Action, test object, applied rule and a cross-tenant denial.
OIDC transaction and PKCEIf nonce was sent, verify its presence and equality in the ID token. RFC 9700 requires PKCE for public clients and recommends it for confidential clients; bind the challenge to the transaction, with S256 recommended.Wrong nonce, replayed code and wrong code_verifier tests in the authorised flow.
Access lifetime and removalSeparate access-token expiry, renewal and application session. RFC 9700 requires sender constraint or rotation to detect refresh-token replay for public clients.Residual access timeline, user departure and an exercised revocation procedure.
Read fictional claims without treating them as proof

Teaching clock: 2026-10-22 at 10:00:00 UTC. The JSON contains a readable header and claims only; no signed JWT serialization is supplied. exp is 10:05:00 UTC and iat is 09:59:00 UTC. The .example domains and identifiers belong solely to this scenario.

{
    "header": {
        "typ": "at+jwt",
        "alg": "RS256",
        "kid": "training-key-01"
    },
    "claims": {
        "iss": "https://identity.example/",
        "sub": "training-subject-17",
        "aud": "https://api.example/evidence",
        "exp": 1792663500,
        "iat": 1792663140,
        "jti": "training-event-001",
        "client_id": "training-console",
        "scope": "evidence:read"
    }
}

Decoding JSON does not validate a signature or establish trust in keys. Where stated, cryptography is an exercise assumption, never a check performed by this page. The profile also has required claims including sub, client_id, iat and jti: the eight-control table is not a complete validator. A subject does not necessarily identify a person; jti alone does not implement replay protection.

Ten review cases: decision, limit and expected evidence

01 · Token intended for the API: continue to business checks

Situation: iss, aud, typ and exp match the fictional contract; evidence:read is present. Signature verification is assumed solely for the exercise.

Decision: continue to operation and object checks, without automatically declaring “access allowed”. Expected evidence: business rule and test object reviewed separately.

02 · Assumed correct signature, wrong audience

Change: aud targets https://api.example/billing rather than the evidence resource. Other assumptions remain the same.

Decision: reject this token for this API. A correct signature does not change its recipient. Expected evidence: no resource content returned and a token-free audience failure record.

03 · Different issuer with plausible claims

Change: iss is https://other-identity.example/. An HTTPS URL does not make it equivalent to the configured issuer.

Decision: reject the issuer match. Expected evidence: exact comparison with https://identity.example/ and a regression test.

04 · Expiry reached at the exact second

Change: exp equals the test clock, 10:00:00 UTC, with zero seconds of leeway in this fixture.

Decision: reject as expired. “Now is before exp” is false at equality; this example does not establish a universal clock policy. Expected evidence: tests before, at and after the boundary under the real policy.

05 · ID token presented as an access token

Change: a fictional ID token has typ = JWT and aud = training-console. It targets the OIDC client.

Decision: reject it as an RFC 9068 JWT access token. Validating it at the OIDC client does not turn it into an access token. Expected evidence: separate validation rules for each token type.

06 · Write scope presented for a read operation

Change: scope is evidence:write while the call requires evidence:read.

Decision: deny the read under the exercise policy, which defines no write → read implication. Scope names and relationships belong to the contract. Expected evidence: an explicit operation/scope matrix, without inferring permissions from names.

07 · Readable JSON, unverified cryptography

Situation: the JSON is readable and values appear to match, but cryptographic validation and trusted keys are not established.

Decision: stop acceptance; the state is unverified. Expected evidence: configured library output and trust-contract checks. Reading claims alone must not release protected data.

08 · Correct token, another tenant’s object

Situation: test token checks are assumed to pass. The requested object belongs to another tenant and business policy denies this read.

Decision: deny the object. evidence:read does not grant access to every account’s evidence. Expected evidence: server-side cross-tenant test and no leakage through content or returned fields.

09 · Audience array containing the expected resource

Change: aud contains https://api.example/evidence and https://api.example/archive. The expected resource is listed.

Decision: this audience check can pass; continue all other checks. An array is not a wildcard. Expected evidence: scopes remain meaningful for the resource, with no ambiguous grant.

10 · ID token nonce differs from the transaction

Separate OIDC transaction, outside the API cases: sent nonce = training-transaction-A; received nonce = training-transaction-B.

Decision: reject the ID token for this transaction under OIDC Core §3.1.3.7. This does not replace PKCE or API rules. Expected evidence: compare with the original transaction and test missing nonce when one was sent.

Six useful acceptance-review records

  • Map clients, issuers, APIs and expected audiences, with an owner for each boundary.
  • Versioned validation contract: format, libraries, trusted keys, algorithms and clock leeway.
  • Action, scope, tenant and object matrix; state denials and the permission implications actually defined.
  • Synthetic fixtures, a fixed clock, negative variants and observed results in the authorised environment.
  • Separate session, access-token and refresh-token timelines during departure, revocation and provider outage.
  • Redacted log: internal transaction reference, policy version, decision reason and date; exclude tokens, codes and secrets.

Primary sources and reading scope

Sources reviewed on

ऑफ़िशियल रेफ़रेंस

रेफ़रेंस इस तरीके को सपोर्ट करते हैं। अपने कॉन्टेक्स्ट के हिसाब से चेक को एडजस्ट करें; वे सर्टिफ़िकेशन नहीं हैं। ओरिजिनल रेफ़रेंस टाइटल और सोर्स डॉक्यूमेंट दूसरी भाषा में हो सकते हैं।

संदर्भ जाँच की तारीख .