/qa-auth-flows:oauth-flow-test-authorfrom qa-auth-flows
Authors OAuth 2.0 / OpenID Connect flow tests for any identity provider: auth code with PKCE, client credentials, refresh-token rotation, state/nonce checks, scope and redirect-URI validation per RFCs.
Ships in qa-auth-flows. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
OAuth 2.0 (RFC 6749) defines four grant types per datatracker.ietf.org/doc/html/rfc6749:
"1. Authorization Code (§1.3.1): The authorization code is obtained by using an authorization server as an intermediary between the client and resource owner. 2. Implicit (§1.3.2): The implicit grant is a simplified authorization code flow optimized for clients implemented in a browser using a scripting language such as JavaScript. 3. Resource Owner Password Credentials (§1.3.3): The resource owner password credentials (i.e., username and password) can be used directly as an authorization grant to obtain an access token. 4. Client Credentials (§1.3.4): The client credentials can be used as an authorization grant when the authorization scope is limited to protected resources under the control of the client."
Per RFC 9700 (OAuth 2.0 Security Best Current Practice, March 2025):
This skill is the per-flow test recipe. The canonical authorization-code + PKCE flow is authored end to end in the Worked example below; the less-common grants and negative cases live in references/per-flow-test-recipes.md.
| Client type | Grant to test | Required tests | Recipe |
|---|---|---|---|
| Browser / SPA / native / mobile | Authorization Code + PKCE (S256) | Happy path + state CSRF + redirect-URI + (OIDC nonce if openid) | Worked example + references |
| Machine-to-machine (M2M) | Client Credentials | Happy path; assert no refresh_token | references |
| Any client holding a refresh token | Refresh Token | Rotation + reuse-detection | references |
| Any OIDC client | Authorization Code + ID Token | Nonce match + scope-downgrade | Worked example + references |
| Legacy Implicit / RO-Password | (none - deprecated per RFC 9700) | Migrate to Auth Code + PKCE | - |
Per RFC 6749 §4.1 (per rfc6749) the flow:
client_id, redirect_uri, response_type=code, scope,
state (RECOMMENDED for CSRF defense per §10.12), nonce
(OIDC), and PKCE params (code_challenge + code_challenge_method).state.grant_type=authorization_code,
code, redirect_uri, client_id, and PKCE code_verifier.PKCE per RFC 7636 §4.2 (rfc7636):
"Two methods are defined:
- plain:
code_challenge = code_verifier- S256:
code_challenge = BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))"
Always use S256; plain defeats the purpose of PKCE.
Test pattern (Python with requests + Playwright for browser flow):
import secrets, hashlib, base64, requests
from urllib.parse import urlparse, parse_qs
def make_pkce_pair():
verifier = secrets.token_urlsafe(64)
challenge = base64.urlsafe_b64encode(
hashlib.sha256(verifier.encode("ascii")).digest()
).rstrip(b"=").decode("ascii")
return verifier, challenge
def test_authz_code_pkce_flow(idp_url, client_id, redirect_uri, browser):
verifier, challenge = make_pkce_pair()
state = secrets.token_urlsafe(32)
nonce = secrets.token_urlsafe(32)
# Step 1: redirect to authorize endpoint
authz_url = (
f"{idp_url}/authorize?"
f"client_id={client_id}&response_type=code&"
f"redirect_uri={redirect_uri}&scope=openid+profile&"
f"state={state}&nonce={nonce}&"
f"code_challenge={challenge}&code_challenge_method=S256"
)
# Browser interaction (simulated via Playwright):
page = browser.new_page()
page.goto(authz_url)
page.fill("#username", "alice")
page.fill("#password", "alicepass")
page.click("#submit")
# Step 3: redirect lands on redirect_uri with code + state
redirected_to = page.url
parsed = urlparse(redirected_to)
query = parse_qs(parsed.query)
assert query["state"][0] == state # RFC §10.12 CSRF defense
code = query["code"][0]
# Step 4: token endpoint
token_response = requests.post(
f"{idp_url}/token",
data={
"grant_type": "authorization_code",
"code": code,
"redirect_uri": redirect_uri,
"client_id": client_id,
"code_verifier": verifier, # PKCE proof
},
)
assert token_response.status_code == 200
body = token_response.json()
assert "access_token" in body
assert body["token_type"] == "Bearer"
The happy path asserts the returned state matches; the negative
state-mismatch test, plus the client-credentials, refresh-rotation,
OIDC-nonce, scope-downgrade, and redirect-URI recipes, are in
references/per-flow-test-recipes.md.
For each OAuth/OIDC client in scope:
| Anti-pattern | Why it fails | Fix |
|---|---|---|
Use PKCE plain method | Defeats PKCE; RFC 7636 §4.2 specifies S256 as recommended | Always S256 (Worked example) |
| Skip state validation in the callback handler | CSRF vulnerable | State CSRF negative test (references) |
| Hardcode redirect_uri prefix matching | Substring match accepts evil URIs | Strict equality (references) |
| Test only the happy path | Negative cases (mismatched state, invalid PKCE, expired token) untested | Negative tests (references) |
| Use Implicit or RO-Password grants in new code | Deprecated per RFC 9700 | Auth Code + PKCE |
keycloak-tests,
auth0-tests,
okta-tests for IdP-specific patterns.keycloak-tests,
auth0-tests,
okta-tests - IdP-specific patternssession-management-test-author - companion: post-auth session lifecycleevals/partner-retires-api-keys-in-nine-days/criteria.json (opens in a new tab)evals/partner-retires-api-keys-in-nine-days/task.md (opens in a new tab)evals/pentest-finding-the-author-says-is-wrong/criteria.json (opens in a new tab)evals/pentest-finding-the-author-says-is-wrong/task.md (opens in a new tab)evals/pkce-exchange-fails-three-times-in-four/criteria.json (opens in a new tab)evals/pkce-exchange-fails-three-times-in-four/task.md (opens in a new tab)evals/red-auth-suite-turned-green-in-one-afternoon/criteria.json (opens in a new tab)evals/red-auth-suite-turned-green-in-one-afternoon/task.md (opens in a new tab)evals/thirty-day-sessions-go-live-on-monday/criteria.json (opens in a new tab)evals/thirty-day-sessions-go-live-on-monday/task.md (opens in a new tab)references/per-flow-test-recipes.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
oauth2, oidc, pkce, authorization-code, client-credentials, refresh-token, security-testing
npx claudepluginhub testland/qa --plugin qa-auth-flows6 skills in this plugin
/auth0-testsUse when an app uses Auth0 and needs tests for its tenant config, login flows or Action scripts: per-PR or namespaced tenants, Universal Login, PKCE, client credentials, Rules and Hooks, and config drift with a0deploy. Generic OAuth flows are oauth-flow-test-author./keycloak-testsUse whenever an app uses self-hosted Keycloak and needs integration tests: a throwaway Keycloak per test class via Testcontainers, realm JSON imports, OIDC discovery, token and introspection endpoints, the admin REST API, password, auth-code, client-credentials and token-exchange flows, and UMA./mfa-flow-test-authorUse when multi-factor login needs automated tests or a new second factor is being added: deterministic TOTP and HOTP codes, SMS or email OTP, WebAuthn passkeys via the Chrome virtual authenticator, recovery codes, enrollment and step-up challenges.Other plugins' skills for the same job