configuring-oauth2-authorization-flow
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
Best use case
configuring-oauth2-authorization-flow is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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
Teams using configuring-oauth2-authorization-flow should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/configuring-oauth2-authorization-flow/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How configuring-oauth2-authorization-flow Compares
| Feature / Agent | configuring-oauth2-authorization-flow | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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
Related Skills
testing-oauth2-implementation-flaws
Tests OAuth 2.0 and OpenID Connect implementations for security flaws including authorization code interception, redirect URI manipulation, CSRF in OAuth flows, token leakage, scope escalation, and PKCE bypass. The tester evaluates the authorization server, client application, and token handling for common misconfigurations that enable account takeover or unauthorized access. Activates for requests involving OAuth security testing, OIDC vulnerability assessment, OAuth2 redirect bypass, or authorization code flow testing.
testing-api-for-broken-object-level-authorization
Tests REST and GraphQL APIs for Broken Object Level Authorization (BOLA/IDOR) vulnerabilities where an authenticated user can access or modify resources belonging to other users by manipulating object identifiers in API requests. The tester intercepts API calls, identifies object ID parameters (numeric IDs, UUIDs, slugs), and systematically replaces them with IDs belonging to other users to determine if the server enforces per-object authorization. This is OWASP API Security Top 10 2023 risk API1. Activates for requests involving BOLA testing, IDOR in APIs, object-level authorization testing, or API access control bypass.
securing-github-actions-workflows
This skill covers hardening GitHub Actions workflows against supply chain attacks, credential theft, and privilege escalation. It addresses pinning actions to SHA digests, minimizing GITHUB_TOKEN permissions, protecting secrets from exfiltration, preventing script injection in workflow expressions, and implementing required reviewers for workflow changes.
secure-workflow-guide
Guide you through Trail of Bits' 5-step secure development workflow. Runs Slither scans, checks special features (upgradeability/ERC conformance/token integration), generates visual security diagrams, helps document security properties for fuzzing/verification, and reviews manual security areas. (project, gitignored)
rg-flow-acset
RG Flow ACSet Skill
reflow
Information Reflow Skill (ERGODIC 0)
implementing-patch-management-workflow
Patch management is the systematic process of identifying, testing, deploying, and verifying software updates to remediate vulnerabilities across an organization's IT infrastructure. An effective patc
implementing-gcp-binary-authorization
Implement GCP Binary Authorization to enforce deploy-time security controls that ensure only trusted, attested container images are deployed to Google Kubernetes Engine and Cloud Run.
flowglad-integration
Zero-webhook billing for AI agents
flow
One-parameter group of diffeomorphisms generated by vector field
exploiting-broken-function-level-authorization
Tests APIs for Broken Function Level Authorization (BFLA) vulnerabilities where regular users can invoke administrative functions or access privileged API endpoints by directly calling them. The tester identifies admin and privileged endpoints, then attempts to access them with regular user credentials by manipulating HTTP methods, URL paths, and request parameters. Maps to OWASP API5:2023 Broken Function Level Authorization. Activates for requests involving BFLA testing, admin endpoint bypass, function-level access control testing, or API privilege escalation.
detecting-broken-object-property-level-authorization
Detect and test for OWASP API3:2023 Broken Object Property Level Authorization vulnerabilities including excessive data exposure and mass assignment attacks.