참고 자료 · 43

OAuth 및 OpenID Connect: 엔드 투 엔드 통합 검증

로그인, 위임 및 데이터 권한을 분리한 후 리디렉션, 토큰, 세션 및 해지를 테스트합니다.

업데이트됨 · 17 min

보안 키 두 개, 빈 카드와 버건디 서류철이 있는 가상의 무인 신원 확인실 AI로 생성한 편집용 일러스트

이 가이드가 달성하는 목표

  • ID와 권한 부여를 분리합니다.
  • 의도치 않은 리디렉션 및 토큰을 거부합니다.
  • 성공만큼 거부도 신중하게 테스트합니다.
  • 퇴사 또는 사고 후 액세스 제거를 확인합니다.

빠른 확인

  • 예상되는 공급자 및 발급자는 무엇입니까?
  • 리디렉션 URI가 정확하게 등록되었습니까?
  • ID 토큰이 액세스 토큰으로 잘못 사용되고 있습니까?
  • 각 리소스에서 소유권을 확인합니까?
  • 어떤 액세스 권한이 취소 후에도 유지됩니까?

단계별 방법

  1. 1

    배포된 흐름을 그립니다.

    공개 또는 기밀 클라이언트, 브라우저, 권한 부여 서버, API 및 OIDC 공급자를 식별합니다. 코드와 토큰의 이동 경로, 저장 위치 및 부여된 역할을 기록합니다. 판매 다이어그램은 실제 배포를 나타내지 않습니다.

    산출물: 흐름, 신뢰 경계 및 구성 요소 소유자.

  2. 2

    로그인 트랜잭션 확인

    클라이언트에 적합한 PKCE를 사용한 코드 흐름. S256, 트랜잭션 바인딩, 등록된 리디렉션 및 위조 요청 방지 기능을 확인합니다. 예상치 못한 URI, 잘못된 검증자, 재실행된 코드 및 예상치 못한 발급자를 테스트합니다. RFC 9700은 클라이언트 유형별로 요구 사항과 권장 사항을 구분합니다.

    산출물: 허용 및 거부 테스트 결과.

  3. 3

    올바른 토큰 유효성 검사

    API는 형식 및 공급자 규칙(서명 또는 인트로스펙션, 발급자, 대상, 만료 및 권한)에 따라 액세스 토큰의 유효성을 검사합니다. OIDC 클라이언트는 ID 토큰을 별도로 검증합니다. 유효한 서명이 있다고 해서 해당 토큰이 이 API에 속한다는 것을 의미하지는 않습니다.

    산출물: 유효성 검사 계약 및 대상/만료 테스트.

  4. 4

    비즈니스 권한 확인

    다른 계정, 하위 역할, 개인 필드 및 관리 작업이 소유한 객체를 테스트합니다. 범위 또는 인증된 게이트웨이는 요청된 리소스에 대한 서버 측 검사를 대체하지 않습니다. 승인된 테스트 계정과 데이터를 사용하십시오.

    결과물: 역할, 객체, 작업 및 예상 거부 매트릭스

  5. 5

    만료 및 해지 테스트

    로컬 세션, 공급자 세션, 액세스 토큰 및 갱신 토큰을 분리합니다. 이탈, 장치 분실, 역할 변경, 서명 키 순환 및 공급자 장애를 테스트합니다. 로그아웃 시 모든 권한이 즉시 해지된다고 가정하는 대신 잔여 액세스 시간을 기록합니다.

    결과물: 액세스 제거 타임라인 및 예외 사항

  6. 6

    비밀 정보를 노출하지 않고 관찰

    트랜잭션 참조, 유효성 검사 결정, 오류 범주 및 구성 버전을 기록합니다. 코드, 토큰 및 비밀 정보는 제외합니다. 진단, 통합 종료 및 유효성 검사를 거친 구성으로 롤백을 준비하고 공급자 변경 후 테스트를 다시 실행합니다.

    산출물: 운영 절차 및 회귀 검사.

가상 예시

예시 상황

예시 상황: 두 클라이언트가 하나의 ID 공급자를 사용합니다. 첫 번째 클라이언트에 유효한 토큰이 두 번째 클라이언트의 API에 제공됩니다.

결정 및 예상 증거

API가 잘못된 대상을 거부하고, 토큰이 없는 추적을 기록하고, 데이터를 반환하지 않습니다. 이 거부는 회귀 테스트가 됩니다.

메커니즘 구분

메커니즘목적검증 또는 제한
OAuth 2.0리소스 접근 위임서버 측 객체 권한
OpenID Connect유효성이 검증된 ID 토큰을 통한 신원 확인발급자, 대상 및 트랜잭션 유효성 검사
애플리케이션 세션애플리케이션 로그인 유지만료, 무효화 및 세션 보호

관리 지표

지표측정 대상첫 번째 조치
거부 수정금지된 경우 실제로 차단됨모든 예상치 못한 승인 수정
권한 취소 지연관련 접근이 사라지는 시간세션과 토큰 별도 확인
유효성 검사 실패원인 및 버전별 거부공격과 구성 오류 구분

일반적인 실수

  • 인증과 권한 부여 혼동 방지
  • 서명 확인 후 모든 대상 허용
  • 광범위한 리디렉션 URI 등록
  • 토큰 로깅 디버깅 용이성 향상

자주 묻는 질문

PKCE가 모든 컨트롤을 대체하나요?

아니요. 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

공식 참조

참조는 방법을 뒷받침합니다. 상황에 맞게 검사를 조정하십시오. 이는 인증이 아닙니다. 원본 참조 제목 및 소스 문서는 다른 언어로 작성되었을 수 있습니다.

참고 자료 확인일 .