oauth-flow-architect
Implements OAuth 2.0 and OpenID Connect authentication flows with proper security, token management, and common provider integrations.
What this skill does
# OAuth Flow Architect
This skill provides guidance for implementing OAuth 2.0 and OpenID Connect (OIDC) authentication flows securely and correctly.
## Core Competencies
- **OAuth 2.0 Flows**: Authorization Code, PKCE, Client Credentials
- **OpenID Connect**: ID tokens, UserInfo, discovery
- **Token Management**: Refresh, revocation, storage
- **Security**: CSRF, token theft, redirect URI validation
## OAuth 2.0 Fundamentals
### The Problem OAuth Solves
```
Without OAuth: With OAuth:
┌──────┐ credentials ┌──────┐ ┌──────┐ ┌──────┐
│ User │──────────────▶│ App │ │ User │ │ App │
└──────┘ └──┬───┘ └──┬───┘ └──┬───┘
│ │ Login at │
│ │ provider │
▼ ▼ │
┌──────┐ ┌──────┐ token ┌──────┐
│Google│ │Google│───────────▶│Google│
└──────┘ └──────┘ └──────┘
App has your password App never sees password
```
### OAuth Roles
| Role | Description | Example |
|------|-------------|---------|
| Resource Owner | User who owns data | End user |
| Client | Application requesting access | Your app |
| Authorization Server | Issues tokens | Google, Auth0 |
| Resource Server | Hosts protected resources | Google API |
### Grant Types Overview
| Grant Type | Use Case | Security Level |
|------------|----------|----------------|
| Authorization Code + PKCE | Web apps, mobile, SPAs | Highest |
| Authorization Code | Traditional server apps | High |
| Client Credentials | Machine-to-machine | High |
| Refresh Token | Token renewal | High |
| Implicit (deprecated) | Legacy SPAs | Low |
| Password (deprecated) | Legacy migrations | Low |
## Authorization Code Flow with PKCE
The recommended flow for all user-facing applications.
### Flow Diagram
```
┌──────┐ ┌─────────────┐ ┌──────────┐
│ User │ │ Client │ │ Auth │
│ │ │ (App) │ │ Server │
└──┬───┘ └──────┬──────┘ └────┬─────┘
│ 1. Click "Login" │ │
│────────────────────────────────────────▶│ │
│ │ 2. Generate code_verifier │
│ │ code_challenge = SHA256() │
│ │ │
│ 3. Redirect to authorization endpoint │ │
│◀────────────────────────────────────────│ │
│ │ │
│ 4. Redirect (login at auth server) │ │
│────────────────────────────────────────────────────────────────────────▶│
│ │ │
│ 5. User authenticates & consents │ │
│◀────────────────────────────────────────────────────────────────────────│
│ │ │
│ 6. Redirect with authorization code │ │
│────────────────────────────────────────▶│ │
│ │ │
│ │ 7. Exchange code + verifier │
│ │ for tokens │
│ │──────────────────────────────▶│
│ │ │
│ │ 8. Access token + ID token │
│ │◀──────────────────────────────│
│ │ │
│ 9. User is logged in │ │
│◀────────────────────────────────────────│ │
```
### Implementation
```python
import secrets
import hashlib
import base64
from urllib.parse import urlencode
class OAuthClient:
"""OAuth 2.0 client with PKCE"""
def __init__(self, config):
self.client_id = config['client_id']
self.client_secret = config.get('client_secret') # Optional with PKCE
self.redirect_uri = config['redirect_uri']
self.authorization_endpoint = config['authorization_endpoint']
self.token_endpoint = config['token_endpoint']
self.scopes = config.get('scopes', ['openid', 'profile', 'email'])
def generate_pkce(self):
"""Generate PKCE code verifier and challenge"""
# Code verifier: 43-128 chars, URL-safe
code_verifier = secrets.token_urlsafe(32)
# Code challenge: SHA256 hash of verifier
digest = hashlib.sha256(code_verifier.encode()).digest()
code_challenge = base64.urlsafe_b64encode(digest).rstrip(b'=').decode()
return code_verifier, code_challenge
def get_authorization_url(self, state=None):
"""Build authorization URL for redirect"""
code_verifier, code_challenge = self.generate_pkce()
# State for CSRF protection
state = state or secrets.token_urlsafe(16)
params = {
'response_type': 'code',
'client_id': self.client_id,
'redirect_uri': self.redirect_uri,
'scope': ' '.join(self.scopes),
'state': state,
'code_challenge': code_challenge,
'code_challenge_method': 'S256'
}
url = f"{self.authorization_endpoint}?{urlencode(params)}"
return {
'url': url,
'state': state,
'code_verifier': code_verifier # Store server-side
}
async def exchange_code(self, code, code_verifier):
"""Exchange authorization code for tokens"""
data = {
'grant_type': 'authorization_code',
'client_id': self.client_id,
'code': code,
'redirect_uri': self.redirect_uri,
'code_verifier': code_verifier
}
# Include client_secret if confidential client
if self.client_secret:
data['client_secret'] = self.client_secret
response = await self.http.post(
self.token_endpoint,
data=data,
headers={'Content-Type': 'application/x-www-form-urlencoded'}
)
if response.status_code != 200:
raise OAuthError(response.json())
return response.json() # {access_token, refresh_token, id_token, ...}
```
### Callback Handler
```python
from flask import request, session, redirect
@app.route('/callback')
async def oauth_callback():
# Verify state to prevent CSRF
state = request.args.get('state')
stored_state = session.get('oauth_state')
if not state or state != stored_state:
return 'Invalid state parameter', 400
# Check for errors
error = request.args.get('error')
if error:
error_desc = request.args.get('error_description', 'Unknown error')
return f'OAuth error: {error_desc}', 400
# Exchange code for tokens
code = request.args.get('code')
code_verifier = session.get('oauth_code_verifier')
try:
tokens = await oauth_client.exchange_code(code, code_verifier)
except OAuthError as e:
return f'Token exchange failed: {e}', 400
# Validate ID token if using OIDC
if 'id_token' in tokens:
user_info = validate_id_token(tokens['id_token'])
else:
user_info = await fetch_userinfo(tokens['accesRelated in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.