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

auth-implementation-patterns

できること

このツールは、ユーザーが誰であるかを確認する(認証)方法と、システム内でユーザーに何が許可されているかを決める(認可)方法を理解し、安全に実装するのに役立ちます。パスワード、ソーシャルログイン、グループ単位のアクセス制御などの方法を扱います。

使う場面

  • ✓ウェブサイトやアプリのログインシステムを作成するとき。
  • ✓データや機能へのアクセスを保護するとき。
  • ✓ユーザーがある機能にアクセスできない理由を調べたいとき。

スキルのリンク

https://github.com/wshobson/agents/blob/main/plugins/developer-essentials/skills/auth-implementation-patterns/SKILL.md

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“管理者だけが特定のレポートを見られるようにするには、どうすればよいですか?”

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

仕組み

認証(誰であるか)と認可(何をできるか)の概念を説明します。トークン(JWT)やセッションを使ってアクセスを管理するパターンを紹介し、セキュリティのヒントも提供します。

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

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

Authentication & Authorization Implementation Patterns

Build secure, scalable authentication and authorization systems using industry-standard patterns and modern best practices.

When to Use This Skill

  • Implementing user authentication systems
  • Securing REST or GraphQL APIs
  • Adding OAuth2/social login
  • Implementing role-based access control (RBAC)
  • Designing session management
  • Migrating authentication systems
  • Debugging auth issues
  • Implementing SSO or multi-tenancy

Core Concepts

1. Authentication vs Authorization

Authentication (AuthN): Who are you?

  • Verifying identity (username/password, OAuth, biometrics)
  • Issuing credentials (sessions, tokens)
  • Managing login/logout

Authorization (AuthZ): What can you do?

  • Permission checking
  • Role-based access control (RBAC)
  • Resource ownership validation
  • Policy enforcement

2. Authentication Strategies

Session-Based:

  • Server stores session state
  • Session ID in cookie
  • Traditional, simple, stateful

Token-Based (JWT):

  • Stateless, self-contained
  • Scales horizontally
  • Can store claims

OAuth2/OpenID Connect:

  • Delegate authentication
  • Social login (Google, GitHub)
  • Enterprise SSO

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

  1. Never Store Plain Passwords: Always hash with bcrypt/argon2
  2. Use HTTPS: Encrypt data in transit
  3. Short-Lived Access Tokens: 15-30 minutes max
  4. Secure Cookies: httpOnly, secure, sameSite flags
  5. Validate All Input: Email format, password strength
  6. Rate Limit Auth Endpoints: Prevent brute force attacks
  7. Implement CSRF Protection: For session-based auth
  8. Rotate Secrets Regularly: JWT secrets, session secrets
  9. Log Security Events: Login attempts, failed auth
  10. Use MFA When Possible: Extra security layer

Common Pitfalls

  • Weak Passwords: Enforce strong password policies
  • JWT in localStorage: Vulnerable to XSS, use httpOnly cookies
  • No Token Expiration: Tokens should expire
  • Client-Side Auth Checks Only: Always validate server-side
  • Insecure Password Reset: Use secure tokens with expiration
  • No Rate Limiting: Vulnerable to brute force
  • Trusting Client Data: Always validate on server
よくある質問

認証と認可の違いは何ですか?

認証は、自分が誰であるかを証明することです(ユーザー名とパスワードなど)。認可は、本人確認の後に何をしてよいかを決めることです(閲覧や編集など)。

JWTとは何ですか?

JWT(JSON Web Token)は、当事者間で情報を安全にやり取りする方法です。ログイン後にユーザーが受け取る通行証のようなもので、システムは毎回データベースを確認しなくても、そのユーザーが誰かを知ることができます。

パスワードを平文で保存してはいけないのはなぜですか?

パスワードを平文で保存するのは非常に危険です。システムに侵入されると、すべてのパスワードが漏れてしまいます。パスワードは「ハッシュ化」して、読めない形で保存する必要があります。

詳細

作者による元の説明

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

repo: wshobson/agents

人気

GitHubのスター
41k
ランキング
#6674
ライセンス
MIT
更新日
2026/10/15

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

0

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

コメント

  • …

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

似ているスキル