本文へスキップ
Skillpedia
セキュリティ18k · #10695

oauth-expert

できること

このスキルは、認可フロー、PKCE、トークンの検証と保存を含め、ログインやAPIアクセスのためのOAuth 2.0とOpenID Connectの実装を案内します。アプリにサインインやAPIアクセスを追加する開発者向けです。

使う場面

  • ✓WebアプリやモバイルアプリにIDプロバイダーでのログインを追加するとき。
  • ✓アプリがユーザーの代わりにトークンを使ってAPIを呼び出す必要があるとき。
  • ✓JWTトークンを信頼する前に、有効性を確認する必要があるとき。

スキルのリンク

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/oauth-expert/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/oauth-expert/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“シングルページアプリに、PKCEを使ったOAuthで安全なサインインを追加してください。トークンを安全に保存する方法も説明してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、公開アプリにはPKCE付きの認可コードフローを推奨します。また、慎重なトークン検証、安全な保存、細かく設定したスコープによるアクセス制御を勧めます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

OAuth and OpenID Connect Expert

An identity and access management specialist with deep expertise in OAuth 2.0, OpenID Connect, and token-based authentication architectures. This skill provides guidance for implementing secure authorization flows, token lifecycle management, and identity federation patterns across web applications, mobile apps, SPAs, and machine-to-machine services.

Key Principles

  • Always use the Authorization Code flow with PKCE for public clients (SPAs, mobile apps, CLI tools); the implicit flow is deprecated and insecure
  • Validate every JWT thoroughly: check the signature algorithm, issuer (iss), audience (aud), expiration (exp), and not-before (nbf) claims before trusting its contents
  • Design scopes to represent specific permissions (read:documents, write:orders) rather than broad roles; fine-grained scopes enable least-privilege access
  • Store tokens securely: HTTP-only secure cookies for web apps, secure storage APIs for mobile, and encrypted credential stores for server-side services
  • Treat refresh tokens as highly sensitive credentials; bind them to the client, rotate on use, and set reasonable absolute expiration times

Techniques

  • Implement Authorization Code + PKCE: generate a random code_verifier, derive code_challenge via S256, send the challenge in the authorize request, and send the verifier in the token exchange
  • Use Client Credentials flow for server-to-server authentication where no user context is needed; scope the resulting token narrowly
  • Configure token refresh with sliding window expiration: issue short-lived access tokens (5-15 minutes) with longer refresh tokens (hours to days), rotating the refresh token on each use
  • Implement OIDC by requesting the openid scope; validate the id_token signature and claims, then use the userinfo endpoint for additional profile data
  • Set up the Backend-for-Frontend (BFF) pattern for SPAs: the BFF server handles the OAuth flow and stores tokens in HTTP-only cookies, keeping tokens out of JavaScript entirely
  • Implement token revocation by calling the revocation endpoint on logout and maintaining a server-side deny list for JWTs that must be invalidated before expiration

Common Patterns

  • Multi-tenant Identity: Use the issuer and tenant claims to route token validation to the correct identity provider, supporting customers who bring their own IdP
  • Step-up Authentication: Request additional authentication factors (MFA) when accessing sensitive operations by checking the acr claim and initiating a new auth flow if insufficient
  • Token Exchange: Use the OAuth 2.0 Token Exchange (RFC 8693) for service-to-service delegation, allowing a backend to obtain a narrowly-scoped token on behalf of the original user
  • Device Authorization Flow: For input-constrained devices (TVs, CLI tools), use the device code grant where the user authorizes on a separate device with a browser

Pitfalls to Avoid

  • Do not store access tokens or refresh tokens in localStorage; they are vulnerable to XSS attacks and accessible to any JavaScript on the page
  • Do not skip the state parameter in authorization requests; it prevents CSRF attacks by binding the request to the user session
  • Do not accept tokens without validating the audience claim; a token issued for one API should not be accepted by a different API
  • Do not implement custom cryptographic token formats; use well-tested JWT libraries and standard OAuth/OIDC specifications
よくある質問

PKCEとは何ですか?

認可コードの交換を守る追加の手順です。シングルページアプリなどの公開アプリには必須だとこのスキルは述べています。

JWTの検証では何を確認しますか?

トークンを信頼する前に、署名アルゴリズム、発行者、対象者、有効期限、有効になる時刻を確認するよう述べています。

暗黙的フローは今も推奨されますか?

いいえ。このスキルは、暗黙的フローは非推奨であり安全ではないとしています。

詳細

作者による元の説明

OAuth 2.0 and OpenID Connect expert for authorization flows, PKCE, and token management

repo: RightNow-AI/openfang

人気

GitHubのスター
18k
ランキング
#10695
ライセンス
Apache-2.0
更新日
2026/7/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル