agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/security/oauth/SKILL.md

oauth

Skill15 starsChanged 42 days agoMITView on GitHub

Expert OAuth 2.0 / 2.1 protocol assistance covering Authorization Code Flow with PKCE, Client Credentials, and token exchange. Use when implementing third-party logins, securing API endpoints, or configuring OAuth servers.

  • Sends data out

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use octocat, linting-neostandard-eslint9 and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • mcollinaSkill

    octocat

    Use this skill whenever the prompt contains any `github.com` URL, even if the user only pastes a link and gives no GitHub-specific keywords. Handles git and GitHub operations using the gh CLI. Triggers include any GitHub link to an issue, pull request, commit, compare page, Actions run, release, discussion, or repository. Covers creating and reviewing PRs, repository security advisories (GHSA), their comments, and fix PRs in their temporary private forks, private vulnerability report discussions, watching CI checks, interactive rebasing, branch cleanup, submodule management, and repository archaeology with git log/blame/bisect.

    Also in 3 projects that use this

  • mcollinaSkill

    linting-neostandard-eslint9

    Configures ESLint v9 flat config and neostandard for JavaScript and TypeScript projects, including migrating from legacy `.eslintrc*` files or the `standard` package. Use when you need to set up or fix linting with `eslint.config.js` or `eslint.config.mjs`, troubleshoot lint errors, configure neostandard rules, migrate from `.eslintrc` to flat config, or integrate linting into CI pipelines and pre-commit hooks.

    Also in 3 projects that use this

  • SubhiSecSkill

    ssti

    Hunt Server-Side Template Injection (SSTI) in Jinja2, Twig, Freemarker, Velocity, Smarty, ERB, Handlebars, Mustache, and Spring (SpEL). Use when input is reflected in a way that suggests template rendering — error pages, email templates, PDF generators, dynamic content systems.

    Also in 4 projects that use this

  • SubhiSecSkill

    xss

    Hunt reflected, stored, and DOM-based Cross-Site Scripting (XSS) including CSP bypass, polyglot payloads, mutation XSS (mXSS), markdown XSS, and template XSS. Use when the user has identified a parameter or input that reflects to the page, or wants to test for XSS in a specific input.

    Also in 3 projects that use this

  • yaklangSkill

    open-redirect

    Open redirect playbook. Use when URL parameters, form actions, or JavaScript sinks control navigation targets and may redirect users to attacker-controlled destinations.

    Also in 3 projects that use this

  • +3 more from mcollina
  • +1 more from SubhiSec

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use OAuth 2.0 for Authentication without OpenID Connect: OAuth provides authorization (access tokens).

    line 116

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

OAuth 2.1

OAuth 2.1 is the consolidation of OAuth 2.0 and its best practices into a single standard. It allows third-party applications to grant limited access to an HTTP service through an authorization server.

When to Use

  • Delegated Authorization Framework: Permitting third-party applications to access user resources without exposing user passwords.
  • Single Sign-On (SSO) Architectures: Authorizing cross-application access tokens across interconnected enterprise platforms.
  • Securing Public and Mobile APIs: Implementing standards-compliant token issuance, verification, and revocation.
  • Machine-to-Machine Service Accounts: Granting automated microservice background daemons scoped API access.

Quick Start

// Client (Frontend) - redirect to Auth Server
const authUrl = `https://auth.example.com/authorize?
  response_type=code&
  client_id=${CLIENT_ID}&
  redirect_uri=${REDIRECT_URI}&
  scope=read:profile&
  code_challenge=${pkceChallenge}&
  code_challenge_method=S256`;

window.location.href = authUrl;

// Callback (Handling the redirect)
const code = new URLSearchParams(window.location.search).get("code");
const tokenResponse = await fetch("https://auth.example.com/token", {
  method: "POST",
  body: JSON.stringify({
    grant_type: "authorization_code",
    code,
    client_id: CLIENT_ID,
    redirect_uri: REDIRECT_URI,
    code_verifier: pkceVerifier, // Proof Key
  }),
});

Core Concepts

The 4 OAuth 2.0 / 2.1 Grant Types

Grant TypeClient TypeUse Case
Authorization Code with PKCEPublic (SPA, Mobile) & Confidential (Web Server)Standard user login and authorization
Client CredentialsConfidential (Backend Daemons)Machine-to-machine background communication
Refresh TokenConfidential & PublicRenewing expired access tokens without re-login
Device AuthorizationInput-constrained (Smart TV, CLI)Authenticating via secondary browser screen

Proof Key for Code Exchange (PKCE) Protocol Flow

Protects authorization codes from interception on public clients:

[ Client ] ──1. Generate Verifier & Challenge (SHA256)──→ Local
[ Client ] ──2. GET /authorize?code_challenge=xyz───────→ [ Auth Server ]
[ Client ] ←─3. Receive Authorization Code─────────────── [ Auth Server ]
[ Client ] ──4. POST /token?code=123&code_verifier=abc──→ [ Auth Server ]
[ Client ] ←─5. Receive Access Token & Refresh Token───── [ Auth Server ]

Scopes & Consent Management

Defines granular operational permissions approved by the resource owner:

POST /oauth/token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=service_analytics
&client_secret=supersecret
&scope=read:reports%20export:csv

Common Patterns

Authorization Code Flow with PKCE (Proof Key for Code Exchange)

Problem: Public clients (SPAs, mobile apps) cannot safely store client secrets, making authorization codes vulnerable to interception.

Solution: Generate cryptographic code verifier and code challenge on the client before initiating authorization:

// Generate Code Verifier and S256 Challenge
const verifier = generateRandomString(64);
const challenge = base64UrlEncode(sha256(verifier));

// Redirect user to authorization endpoint
const authUrl =
  `https://auth.example.com/oauth/authorize?` +
  `response_type=code&client_id=spa-client&` +
  `redirect_uri=${encodeURIComponent(redirectUri)}&` +
  `code_challenge=${challenge}&code_challenge_method=S256`;

Best Practices

Do:

  • Enforce OAuth 2.1 Recommendations: Deprecate legacy Implicit Grant and Resource Owner Password Credentials (ROPC) completely.
  • Mandate PKCE for All Authorization Code Flows: Require PKCE for confidential clients as well as public clients.
  • Implement Refresh Token Rotation: Invalidate previous refresh tokens upon each exchange to detect token reuse and theft immediately.
  • Validate Redirect URIs Strictly: Use exact string matching against registered redirect URIs; never use wildcard regular expressions.

Don't:

  • Use OAuth 2.0 for Authentication without OpenID Connect: OAuth provides authorization (access tokens); OIDC adds authentication (ID tokens).
  • Pass access tokens in URL query strings: Query parameters leak into browser histories, server access logs, and referrer headers.
  • Grant broad wildcard scopes: Enforce least privilege by issuing fine-grained scopes tailored to the application's actual needs.

Troubleshooting

ErrorCauseSolution
invalid_grantCode expired or reused.Get a new authorization code.
redirect_uri_mismatchURI doesn't match allowlist.Check dashboard settings exactly.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.