doc-identity
Skill0 starsChanged 8 months agoMITView on GitHub
Agach identity system: authentication (JWT, bcrypt), SSO/OIDC, teams, users, nodes, daemon onboarding, token management
In this repository10 other files it gives its agents.
- doc-api-routesSkill
- doc-architectureSkill
- doc-business-rulesSkill
- doc-daemonSkill
- doc-databaseSkill
- doc-dependenciesSkill
- doc-frontendSkill
- doc-notificationsSkill
- doc-shared-packagesSkill
- doc-testingSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 78
All mutations require actor.IsAdmin()
- Distinctive: line 86
All mutations require node ownership (node.OwnerUserID == actor.UserID)
- Very specific: line 138
Default admin seeded on first run: admin@agach.local / admin (env overridable)
- Distinctive: line 141
Create repositories (runs migrations)
- Distinctive: line 142
Create SSOService if providers configured
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agach Identity System (internal/identity/)
Overview
Authentication, authorization, SSO, team management, and daemon node onboarding.
Domain Types
Core (domain/types.go)
UserID,TeamID— UUID-based identifiersMemberRole— "admin" or "member"Team— ID, Name, Slug, Description, timestampsUser— ID, Email, DisplayName, PasswordHash, SSOProvider, SSOSubject, Role, TeamID, timestampsActor— UserID, Email, Role +IsAdmin()method (request-scoped auth context)DaemonActor— NodeID, OwnerUserID, Mode +IsZero()method
Nodes (domain/node.go)
NodeID,OnboardingCodeID— UUID-based identifiersNodeMode— "default" or "shared"NodeStatus— "active" or "revoked"Node— ID, OwnerUserID, Name, Mode, Status, RefreshTokenHash, LastSeenAt, RevokedAt, timestampsOnboardingCode— ID, Code (6-digit), CreatedByUserID, NodeMode, NodeName, ExpiresAt, UsedAt, UsedByNodeIDNodeAccess— ID, NodeID, UserID (nullable), TeamID (nullable)
SSO Config (domain/ssoconfig.go)
SsoProvider— Name, Icon, SAML (nullable), OIDC (nullable)OIDCConfig— IssuerURL, ClientID, ClientSecret, RedirectURL, ScopesSAMLConfig— MetadataURL, EntityID, ACSURL, Certificate (not yet supported)
Token TTLs (domain/ttl.go)
- DefaultRefreshTokenTTL = 7 days
- DefaultRememberMeTokenTTL = 30 days
- DefaultDaemonJWTTTL = 30 days
Errors (domain/errors.go)
ErrUnauthorized, ErrForbidden, ErrUserNotFound, ErrInvalidCredentials, ErrEmailAlreadyExists, ErrSSOUserNoPassword, ErrTeamNotFound, ErrTeamSlugConflict, ErrSSOProviderNotFound, ErrSSONotSupported, ErrNodeNotFound, ErrNodeRevoked, ErrOnboardingCodeNotFound/Expired/Used
Repository Interfaces
UserRepository— Create, FindByID, FindByEmail, FindBySSO, Update, ListAll, ListByTeamTeamRepository— Create, FindByID, FindBySlug, List, Update, DeleteNodeRepository— Create, FindByID, ListByOwner, ListActiveByOwner, Update, UpdateLastSeenOnboardingCodeRepository— Create, FindByCode, MarkUsed (FOR UPDATE lock), DeleteExpiredNodeAccessRepository— GrantUser/Team, RevokeUser/Team, ListByNode, HasAccess (ON CONFLICT DO NOTHING)
Service Interfaces
AuthCommands— Register, Login, LoginSSO, RefreshToken, Logout, UpdateProfile, ChangePassword, RefreshDaemonTokenAuthQueries— ValidateJWT, ValidateDaemonJWT, GetCurrentUserTeamCommands— CreateTeam, UpdateTeam, DeleteTeam, AddUserToTeam, RemoveUserFromTeam, SetUserRoleTeamQueries— ListTeams, GetTeam, ListUsers, ListTeamMembersOnboardingCommands— GenerateCode, CompleteOnboardingNodeCommands— RevokeNode, UpdateNodeAccess, RenameNodeNodeQueries— ListNodes, GetNode
App Layer
Auth (app/auth.go)
- bcrypt cost 12, min password 8 chars, min secret 32 bytes
- Access token TTL: 15 minutes
- Refresh token: 7 days (30 days with remember_me)
- JWT claims: sub, email, role, token_type, iat, exp
- Daemon JWT claims: sub (nodeID), owner_id, mode, token_type
SSO (app/sso.go)
- OIDC only (SAML not yet supported)
- Full flow: discovery → code exchange → JWK fetch → ID token validation
- RSA + ECDSA (P-256/P-384/P-521) key support
- Auto-creates user on first SSO login
Teams (app/teams.go)
- All mutations require
actor.IsAdmin()
Onboarding (app/onboarding.go)
- 6-digit numeric codes with uniqueness retries (3 attempts)
- 15-minute code expiry
- Refresh token: 32 random bytes, bcrypt hashed (cost 12)
Nodes (app/nodes.go)
- All mutations require node ownership (node.OwnerUserID == actor.UserID)
- UpdateNodeAccess requires NodeModeShared
HTTP Routes
Auth (rate limited: 5 requests / 15 minutes per IP)
POST /api/auth/register — Register new user
POST /api/auth/login — Login (email/password, remember_me)
POST /api/auth/refresh — Refresh access token (refresh_token cookie)
POST /api/auth/logout — Clear refresh_token cookie
GET /api/auth/me — Get current user
PATCH /api/auth/me — Update display name
POST /api/auth/me/password — Change passwordSSO
GET /api/auth/sso/providers — List configured providers
GET /api/auth/sso/{provider}/authorize — OIDC authorization initiation
GET /api/auth/sso/{provider}/callback — OIDC callback (returns #sso_token=...)Teams
GET /api/identity/teams — List teams
POST /api/identity/teams — Create team (admin)
DELETE /api/identity/teams/{id} — Delete team (admin)
GET /api/identity/users — List users (admins see emails)
PUT /api/identity/users/{id}/team — Add user to team (admin)
DELETE /api/identity/users/{id}/team — Remove from team (admin)
PUT /api/identity/users/{id}/role — Set user role (admin)Onboarding & Nodes
POST /api/onboarding/codes — Generate onboarding code (auth required)
POST /api/onboarding/complete — Complete onboarding (unauthenticated)
POST /api/daemon/refresh — Refresh daemon token (unauthenticated)
GET /api/nodes — List nodes (auth required)
GET /api/nodes/{id} — Get node (ownership required)
DELETE /api/nodes/{id} — Revoke node (ownership required)
PATCH /api/nodes/{id}/name — Rename node
PUT /api/nodes/{id}/access — Update access grants (shared mode only)Security
- Bcrypt password hashing (cost 12)
- HMAC-SHA256 JWT signing (≥ 32 byte secret)
- pgp_sym_encrypt for sensitive DB columns (password_hash, sso_subject)
- HttpOnly, Secure, SameSite=Strict cookies
- OIDC state verification with HMAC signatures
- Default admin seeded on first run: admin@agach.local / admin (env overridable)
Init Wiring (init.go)
- Create repositories (runs migrations)
- Create SSOService if providers configured
- Wire auth service (with/without nodes)
- Wire team, onboarding, node services
- Seed default admin if no users exist
- Return System struct with all services
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

