Skip to main content
skill CX Codex

configuring-oauth2-authorization-flow — Claude Code skill

The configuring-oauth2-authorization-flow skill guides OAuth 2.0 setup for web, mobile, SPA, and machine clients. Use it when adding authorization or reviewing an existing flow.

Apache-2.0 301 installs ★ 36,511 updated 2026-08-31

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill configuring-oauth2-authorization-flow -a claude-code
Open on GitHub

What configuring-oauth2-authorization-flow does

The skill guides flow selection for OAuth 2.0 implementations. It covers Authorization Code with PKCE, Client Credentials, and Device Authorization Grant, then walks through redirect parameters, state checks, scope boundaries, and token exchange. The material also addresses OAuth 2.1 requirements and common attack paths.

Its workflow includes secure token storage, refresh-token rotation, revocation, expiry checks, DPoP, and exact redirect URI matching. It also explains how to keep client secrets outside source code and how to enforce scopes at the resource server. Testing is intended for an authorized test or lab environment.

Python 3.8+ and the required dependencies are prerequisites, along with familiarity with identity and access management. Without Python 3.8+, the documented setup requirements are not met.

What it helps with

  • choose a grant for each client type
  • add PKCE to an authorization-code flow
  • define least-privilege OAuth scopes
  • rotate and revoke refresh tokens
  • test state and redirect URI protection

Example prompts for the agent

  • Configure Authorization Code with PKCE for this SPA and validate the state value.
  • Design least-privilege scopes for read:users, write:orders, and admin:settings.
  • Review the Client Credentials setup and add refresh-token rotation where it applies.

How to install configuring-oauth2-authorization-flow

1Skills CLI (Vercel)

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill configuring-oauth2-authorization-flow -a claude-code

2Manually: put the files in place

~/.claude/skills/configuring-oauth2-authorization-flow/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/configuring-oauth2-authorization-flow/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about configuring-oauth2-authorization-flow

How do I install configuring-oauth2-authorization-flow in Claude Code?

Run npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill configuring-oauth2-authorization-flow -a claude-code, then check ~/.claude/skills/configuring-oauth2-authorization-flow/SKILL.md.

What does configuring-oauth2-authorization-flow do?

It guides OAuth 2.0 flow setup, PKCE, scope design, and token lifecycle controls. It also covers hardening steps such as state validation, token revocation, and strict redirect matching.

Which OAuth 2.0 grants does the skill cover?

It covers Authorization Code with PKCE for web, mobile, and SPA clients, Client Credentials for machine-to-machine access, and Device Authorization Grant for input-constrained devices.

Source text

SKILL.md · Apache-2.0
---
name: configuring-oauth2-authorization-flow
description: Configures secure OAuth 2.0 authorization flows, including Authorization
  Code with PKCE, Client Credentials, and Device Authorization Grant, covering flow
  selection, PKCE implementation, token lifecycle management, and scope design per
  OAuth 2.1. Use when implementing or hardening OAuth 2.0 authentication/authorization
  for web, mobile, SPA, or machine-to-machine clients.
domain: cybersecurity
subdomain: identity-access-management
tags:
- iam
- identity
- access-control
- authentication
- authorization
- oauth2
- oidc
- pkce
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- PR.AA-01
- PR.AA-02
- PR.AA-05
- PR.AA-06
mitre_attack:
- T1528
- T1550.001
- T1539
- T1606.001
- T1212
mitre_f3:
  version: '1.1'
  tactics:
  - initial-access
  - positioning
  techniques:
  - id: T1550.001
    name: 'Use Alternate Authentication Material: Application Access Token'
    tactic: initial-access
    source: attack
  - id: F1004
    name: Access with Stolen Session Cookie
    tactic: initial-access
    source: f3
  - id: F1006
    name: Account Takeover
    tactic: initial-access
    source: f3
  - id: T1539
    name: Steal Web Session Cookie
    tactic: positioning
    source: attack
---
# Configuring OAuth 2.0 Authorization Flow

## Overview
Configure secure OAuth 2.0 authorization flows including Authorization Code with PKCE, Client Credentials, and Device Authorization Grant. This skill covers flow selection, PKCE implementation, token lifecycle management, scope design, and alignment with OAuth 2.1 security requirements.


## When to Use

- When deploying or configuring configuring oauth2 authorization flow capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation

## Prerequisites

- Familiarity with identity access management concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities

## Objectives
- Implement Authorization Code flow with PKCE for public and confidential clients
- Configure Client Credentials flow for machine-to-machine communication
- Design least-privilege scope hierarchies
- Implement secure token storage, refresh, and revocation
- Apply OAuth 2.1 best practices and RFC 9700 security recommendations
- Validate token integrity and prevent common OAuth attacks

## Key Concepts

### OAuth 2.0 Grant Types
1. **Authorization Code + PKCE**: Recommended for all client types (web, mobile, SPA). PKCE is mandatory in OAuth 2.1.
2. **Client Credentials**: Machine-to-machine authentication without user context.
3. **Device Authorization Grant (RFC 8628)**: For input-constrained devices (smart TVs, CLI tools).
4. **Refresh Token**: Long-lived token to obtain new access tokens without re-authentication.

### PKCE (Proof Key for Code Exchange)
PKCE (RFC 7636) prevents authorization code interception attacks:
1. Client generates random `code_verifier` (43-128 characters, unreserved URI chars)
2. Client computes `code_challenge = BASE64URL(SHA256(code_verifier))`
3. Authorization request includes `code_challenge` and `code_challenge_method=S256`
4. Token request includes original `code_verifier`
5. Server validates `SHA256(code_verifier)` matches stored `code_challenge`

### Token Types
- **Access Token**: Short-lived (5-60 min), bearer or DPoP-bound
- **Refresh Token**: Long-lived, single-use with rotation
- **ID Token (OIDC)**: JWT containing user identity claims

## Workflow

### Step 1: Authorization Code Flow with PKCE
1. Generate cryptographically random code_verifier (min 43 chars)
2. Compute code_challenge using S256 method
3. Redirect user to authorization endpoint with parameters:
   - response_type=code
   - client_id, redirect_uri, scope, state
   - code_challenge, code_challenge_method=S256
4. User authenticates and consents
5. Authorization server redirects with authorization code
6. Exchange code + code_verifier for tokens at token endpoint
7. Validate state parameter matches original value

### Step 2: Scope Design
- Define granular scopes: `read:users`, `write:orders`, `admin:settings`
- Follow least-privilege: request minimum scopes needed
- Implement scope validation on resource server
- Document scope hierarchy and consent requirements

### Step 3: Token Security
- Store tokens securely (httpOnly cookies for web, keychain for mobile)
- Implement token refresh with rotation (one-time-use refresh tokens)
- Set appropriate expiration: access tokens 5-15 min, refresh tokens 8-24 hrs
- Enable DPoP (Demonstration of Proof-of-Possession) for sender-constrained tokens
- Implement token revocation endpoint

### Step 4: Client Credentials Flow
1. Register service client with client_id and client_secret
2. Request token: POST /oauth/token with grant_type=client_credentials
3. Include scope for required permissions
4. Store client_secret securely (vault, env vars, not code)
5. Implement certificate-based client authentication for higher assurance

### Step 5: Security Hardening
- Enforce PKCE for all authorization code flows
- Use exact redirect URI matching (no wildcards)
- Implement CSRF protection with state parameter
- Enable refresh token rotation and revocation on reuse detection
- Apply RFC 9700 security best practices
- Block implicit grant and ROPC (removed in OAuth 2.1)

## Security Controls
| Control | NIST 800-53 | Description |
|---------|-------------|-------------|
| Access Control | AC-3 | Token-based access enforcement |
| Authentication | IA-5 | Client credential management |
| Session Management | SC-23 | Token lifecycle management |
| Audit | AU-3 | Log all token issuance and revocation |
| Cryptographic Protection | SC-13 | PKCE and token signing |

## Common Pitfalls
- Using implicit grant (removed in OAuth 2.1) instead of authorization code + PKCE
- Storing tokens in localStorage (XSS vulnerable) instead of httpOnly cookies
- Not validating state parameter enabling CSRF attacks
- Using wildcard redirect URIs allowing open redirect exploitation
- Not implementing refresh token rotation allowing token theft persistence

## Verification
- [ ] Authorization Code + PKCE flow completes successfully
- [ ] PKCE code_challenge validated at token endpoint
- [ ] State parameter prevents CSRF
- [ ] Access tokens expire within configured lifetime
- [ ] Refresh token rotation issues new refresh token each use
- [ ] Token revocation invalidates both access and refresh tokens
- [ ] Client Credentials flow works for service-to-service calls
- [ ] Scopes correctly enforced at resource server

© mahipal · Apache-2.0 · mukul975/Anthropic-Cybersecurity-Skills

Similar skills

All skills for Security →

From the same set152

The whole set →
auditing-aws-s3-bucket-permissions auditing-aws-s3-bucket-permissions audits AWS S3 bucket permissions, public access, bucket policies, and encryption via AWS CLI and Prowler. Helps baseline new cloud accounts and verify compliance for SOC 2 or PCI DSS. CX Codex +1 307installs analyzing-office365-audit-logs-for-compromise analyzing-office365-audit-logs-for-compromise parses Office 365 Unified Audit Logs via Microsoft Graph API to spot inbox forwarding rules, mailbox delegation, and rogue OAuth app grants. CX Codex +1 304installs exploiting-jwt-algorithm-confusion-attack The exploiting-jwt-algorithm-confusion-attack skill tests JWT authentication for algorithm switching, alg:none, and key-header issues. Use it for authorized API security checks. CX Codex +1 303installs analyzing-powershell-empire-artifacts The analyzing-powershell-empire-artifacts skill hunts for PowerShell Empire traces in Windows event logs and builds a report with IOCs, decoded payloads, and MITRE ATT&CK mappings. CX Codex +1 303installs exploiting-broken-function-level-authorization The exploiting-broken-function-level-authorization skill for Claude Code tests APIs for OWASP API5:2023: whether low-privilege users can invoke admin functions by manipulating HTTP methods, paths, and parameters. CX Codex +1 299installs performing-web-application-scanning-with-nikto performing-web-application-scanning-with-nikto teaches coding agents to run Nikto for web server vulnerability scanning, configuration audits, and SSL checks. Useful during planned audits or incident response. CX Codex +1 299installs exploiting-server-side-request-forgery exploiting-server-side-request-forgery — a skill for discovering and exploiting SSRF vulnerabilities in web applications: access cloud metadata, internal services, and restricted network resources during authorized penetration tests. CX Codex +1 296installs implementing-jwt-signing-and-verification implementing-jwt-signing-and-verification is a Claude Code skill for building JWT signing and verification. It activates for authentication work or audits of token checks. CX Codex +1 294installs

Project sponsors

Companies that keep this analytics open