Auth integrator
Welcome to the skill-jam βοΈπ
npx -y skills add VRIL-LABS/skill-jam --skill auth-integratorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Adds authentication and authorization flows β OAuth 2.0, JWT, RBAC, API keys β to an existing application. Invoke when asked to add login, implement authentication, set up OAuth, add JWT tokens, implement role-based access control, or secure API endpoints.
SKILL.md
6.7 KB, ~1.5k tokens by cl100k_base, as published. Nobody here has run it
Auth Integrator
Designs and implements authentication (verifying identity) and authorization (controlling access) flows for existing applications β covering OAuth 2.0, JWT sessions, API key authentication, and role-based access control (RBAC).
When to Use
- User asks to "add authentication", "implement login", or "secure these endpoints"
- An API needs API key or JWT-based authentication
- OAuth 2.0 social login (Google, GitHub, etc.) needs to be integrated
- Role-based permissions need to be enforced on routes or resources
- Existing auth implementation has security gaps
- User asks to implement refresh token rotation or session management
Process
-
Clarify the auth requirements:
- Authentication type: session cookies, JWT (stateless), API keys, OAuth 2.0, SAML, magic links
- Identity providers: local (username/password), Google, GitHub, Microsoft, etc.
- Authorization model: no authz, simple auth check, RBAC (roles), ABAC (attributes)
- Client type: SPA (cookie vs. token tradeoffs), mobile, server-to-server
- Framework: Express, FastAPI, Django, Spring Boot, etc.
-
Design the authentication flow based on the chosen type:
JWT (Stateless Bearer Tokens):
- POST
/auth/loginβ validate credentials β issueaccess_token(short-lived, 15min) +refresh_token(long-lived, 7β30d, stored in httpOnly cookie or DB) - Protected routes: middleware extracts
Authorization: Bearer <token>, verifies signature and expiry, attachesreq.user - POST
/auth/refreshβ validate refresh token β issue new access token + rotate refresh token - POST
/auth/logoutβ invalidate refresh token (add to denylist or delete from DB)
OAuth 2.0 / OIDC:
- GET
/auth/oauth/googleβ redirect to provider authorization URL withstateandPKCE - GET
/auth/callbackβ exchangecodefor tokens β fetch user profile β upsert user in DB β issue local session/JWT - Always verify
stateparam to prevent CSRF
API Keys:
- Generate cryptographically random key (32+ bytes):
crypto.randomBytes(32).toString('hex') - Store only a hashed version (SHA-256) in the database, return the plaintext once
- Middleware: extract
X-API-Keyheader β hash it β look up in DB β attach associated user/scope
- POST
-
Design the authorization model:
- RBAC: define roles (
admin,editor,viewer), assign permissions per role, enforce in middleware - Resource ownership: check
resource.ownerId === req.user.idbefore mutations - Implement
requireRole(role)andrequirePermission(permission)middleware factories
- RBAC: define roles (
-
Implement secure password handling if using local auth:
- Hash with
bcrypt(cost factor 12) orargon2id - Never store, log, or return plaintext passwords
- Implement rate limiting on login endpoint (max 5 attempts / 15min per IP)
- Hash with
-
Generate the implementation files:
- Auth router with login, register, refresh, logout endpoints
- Auth middleware for protecting routes
- JWT utility (sign, verify, refresh)
- User model with auth fields
- Role/permission definitions
-
Add security headers and configurations:
- httpOnly, Secure, SameSite=Strict cookies for refresh tokens
- Short expiry for access tokens
- Token rotation on every refresh
Output Format
### Files Generated
- `src/auth/auth.router.ts` β POST /auth/register, /auth/login, /auth/refresh, /auth/logout
- `src/auth/auth.service.ts` β validateCredentials, issueTokens, refreshTokens, revokeToken
- `src/auth/auth.middleware.ts`β requireAuth, requireRole(role), requirePermission(perm)
- `src/auth/jwt.util.ts` β signAccessToken, signRefreshToken, verifyToken
- `src/models/user.model.ts` β id, email, passwordHash, role, refreshTokens[]
src/auth/auth.middleware.ts
import { Request, Response, NextFunction } from 'express';
import { verifyToken } from './jwt.util';
export function requireAuth(req: Request, res: Response, next: NextFunction) {
const authHeader = req.headers.authorization;
if (!authHeader?.startsWith('Bearer ')) {
return res.status(401).json({ error: 'Missing or invalid Authorization header' });
}
try {
const payload = verifyToken(authHeader.slice(7));
req.user = payload;
next();
} catch {
return res.status(401).json({ error: 'Invalid or expired token' });
}
}
export function requireRole(...roles: string[]) {
return (req: Request, res: Response, next: NextFunction) => {
if (!req.user || !roles.includes(req.user.role)) {
return res.status(403).json({ error: 'Insufficient permissions' });
}
next();
};
}
Examples
Example Input
Add JWT authentication to an Express.js API.
Users should be able to register with email/password.
Admin and user roles. Admins can access /admin/* routes.
Example Output (summary)
Implementation:
- POST /auth/register β hash password (bcrypt cost 12), create user (role: 'user'), return JWT
- POST /auth/login β verify credentials, return access token (15min) + set httpOnly refresh cookie
- POST /auth/refresh β validate cookie refresh token, rotate and return new access token
- POST /auth/logout β revoke refresh token, clear cookie
Middleware:
- requireAuth β validates Bearer JWT on all protected routes
- requireRole('admin') β applied to all /admin/* routes
Security:
- Passwords hashed with bcrypt (cost 12)
- Access tokens expire in 15 minutes
- Refresh tokens stored in DB, rotated on use, revoked on logout
- Rate limiting: 5 login attempts per IP per 15 minutes
Boundaries
- Do NOT implement authentication without HTTPS β note that TLS must be configured at the infrastructure level.
- Do NOT use
Math.random()or weak hashing for token generation β always usecrypto.randomBytes()or equivalent. - Do NOT use
alg: noneor symmetric JWT secrets shorter than 256 bits. - Do NOT implement "remember me" by simply extending JWT expiry β use proper refresh token rotation.
- Do NOT store sensitive auth tokens in
localStoragefor web clients β prefer httpOnly cookies. - If the user requests SAML or enterprise SSO, note that these are complex and recommend using an identity provider library or service (Auth0, Okta, Keycloak) rather than building from scratch.
- Always implement rate limiting on authentication endpoints β note if the framework for this is not detected in the project.