Auth Implementation Patterns

Auth Implementation Patterns

Teaches authentication and authorization patterns including JWT, OAuth2, sessions and RBAC so an agent can build and debug secure access control for apps and APIs.

Skill files2 files

references/

SKILL.md84 lines
1
---
2
name: auth-implementation-patterns
3
description: 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.
4
---
5
6
# Authentication & Authorization Implementation Patterns
7
8
Build secure, scalable authentication and authorization systems using industry-standard patterns and modern best practices.
9
10
## When to Use This Skill
11
12
- Implementing user authentication systems
13
- Securing REST or GraphQL APIs
14
- Adding OAuth2/social login
15
- Implementing role-based access control (RBAC)
16
- Designing session management
17
- Migrating authentication systems
18
- Debugging auth issues
19
- Implementing SSO or multi-tenancy
20
21
## Core Concepts
22
23
### 1. Authentication vs Authorization
24
25
**Authentication (AuthN)**: Who are you?
26
27
- Verifying identity (username/password, OAuth, biometrics)
28
- Issuing credentials (sessions, tokens)
29
- Managing login/logout
30
31
**Authorization (AuthZ)**: What can you do?
32
33
- Permission checking
34
- Role-based access control (RBAC)
35
- Resource ownership validation
36
- Policy enforcement
37
38
### 2. Authentication Strategies
39
40
**Session-Based:**
41
42
- Server stores session state
43
- Session ID in cookie
44
- Traditional, simple, stateful
45
46
**Token-Based (JWT):**
47
48
- Stateless, self-contained
49
- Scales horizontally
50
- Can store claims
51
52
**OAuth2/OpenID Connect:**
53
54
- Delegate authentication
55
- Social login (Google, GitHub)
56
- Enterprise SSO
57
58
## Detailed patterns and worked examples
59
60
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
61
62
## Best Practices
63
64
1. **Never Store Plain Passwords**: Always hash with bcrypt/argon2
65
2. **Use HTTPS**: Encrypt data in transit
66
3. **Short-Lived Access Tokens**: 15-30 minutes max
67
4. **Secure Cookies**: httpOnly, secure, sameSite flags
68
5. **Validate All Input**: Email format, password strength
69
6. **Rate Limit Auth Endpoints**: Prevent brute force attacks
70
7. **Implement CSRF Protection**: For session-based auth
71
8. **Rotate Secrets Regularly**: JWT secrets, session secrets
72
9. **Log Security Events**: Login attempts, failed auth
73
10. **Use MFA When Possible**: Extra security layer
74
75
## Common Pitfalls
76
77
- **Weak Passwords**: Enforce strong password policies
78
- **JWT in localStorage**: Vulnerable to XSS, use httpOnly cookies
79
- **No Token Expiration**: Tokens should expire
80
- **Client-Side Auth Checks Only**: Always validate server-side
81
- **Insecure Password Reset**: Use secure tokens with expiration
82
- **No Rate Limiting**: Vulnerable to brute force
83
- **Trusting Client Data**: Always validate on server
84

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…