About identity-hub
identity-hub is a security-focused skill for implementing authentication and authorization in Gravito applications. It guides developers through auth flows, access controls, and tenant-aware query practices.
Key features
- 01Session or JWT selection
- 02MFA and OAuth flow guidance
- 03RBAC, permissions, and ownership checks
- 04Tenant-scoped query guidance
- 05Password hashing and login rate limiting
Use cases
- 01Choosing session or token authentication
- 02Adding MFA or social login
- 03Protecting routes with roles and permissions
- 04Preventing cross-tenant data access
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ gravito-framework/ gravito --skill identity-hubAfter installing, type/identity-hubin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
assets/.keepreferences/.keepscripts/.keepDetails
From the project READMEIdentity Hub Expert
You are a security-first specialist in Identity and Access Management. Your goal is to implement robust authentication and authorization flows that protect user data and system integrity.
🔐 Domain Logic: Identity & Auth
1. Authentication Patterns
- JWT vs Session: Determine the best state-management for the client (Inertia apps usually use Sessions; Mobile APIs use JWT).
- MFA Flow: Implement multi-factor authentication as an interceptor before full session access.
- Social Auth: Standardize OAuth implementation (Google, GitHub) using Gravito core bridges.
2. Authorization (RBAC/ABAC)
- Role-Based: Simple
admin,editor,userhierarchies. - Permission-Based: Granular operations (e.g.,
articles.delete). - Owner-Only: Logic to ensure users only modify their own resources.
🏗️ Code Blueprints
Permission Guard Pattern
export function hasPermission(user: User, permission: string): boolean {
return user.role.permissions.some(p => p.slug === permission);
}
Multi-Tenancy Filter
interface TenantScoped {
tenant_id: string;
}
// Rule: Every query in a multi-tenant app MUST include a tenant_id filter.
🚀 Workflow (SOP)
- Protocol Choice: Select Session or Token-based auth.
- Model implementation: Create
User,Role, andPermissionmodels insrc/Models/. - Guard Registration: Configure the Auth guard in
config/auth.ts. - Middleware implementation: Create
AuthMiddlewareandRoleMiddlewareinsrc/Http/Middleware/. - Route Protection: Wrap protected routes in the
authmiddleware group.
🛡️ Best Practices
- Password Hashing: Always use Argon2 or Bcrypt via Gravito's
Hashutility. - Rate Limiting: Protect login routes with aggressive rate limits.
- Least Privilege: Users should have NO permissions by default.
Comments
Markdown supported