agentleFS
adymireadymire/CraftLayer/skills/authentication-and-rbac/SKILL.md

authentication-and-rbac

Skill0 starsChanged 3 days agoMITView on GitHub

Design identity and authorization flows that enforce least privilege, tenant isolation, and safe session handling.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use for login, sessions, invitations, organization membership, roles, permissions, API credentials, or authorization changes.

    line 10
  2. Distinctive:

    Do not invent a custom cryptographic protocol or treat frontend hiding as authorization.

    line 15
  3. Distinctive:

    Use secure session/token storage, expiration, rotation, revocation, and CSRF protections as applicable.

    line 31
  4. Distinctive:

    Default to least privilege and deny by default.

    line 40
  5. Distinctive:

    Never store plaintext passwords or expose credentials in logs.

    line 41
  6. Distinctive:

    Use established identity libraries/providers where suitable.

    line 42
  7. Distinctive:

    Test anonymous, ordinary, admin, revoked, cross-tenant, expired-session, and background-job access paths.

    line 59

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Authentication and RBAC

When to use

Use for login, sessions, invitations, organization membership, roles, permissions, API credentials, or authorization changes.

When not to use

Do not invent a custom cryptographic protocol or treat frontend hiding as authorization.

Inputs and assumptions

Identify identity provider, account lifecycle, tenant model, roles, resources, session requirements, recovery, audit, and regulatory constraints.

Workflow

  1. Separate authentication (who) from authorization (may do what).
  2. Define resource/action permissions and inheritance explicitly.
  3. Enforce checks server-side at every access path, including APIs, jobs, exports, and nested resources.
  4. Prevent cross-tenant access by deriving scope from trusted identity and membership, not user-supplied tenant IDs alone.
  5. Use secure session/token storage, expiration, rotation, revocation, and CSRF protections as applicable.
  6. Make invitation, role change, recovery, and account deletion flows resistant to enumeration and unauthorized takeover.
  7. Audit security-sensitive changes and test both allowed and denied behavior.

Decision rules

  • Default to least privilege and deny by default.
  • Never store plaintext passwords or expose credentials in logs.
  • Use established identity libraries/providers where suitable.
  • Re-check permission when asynchronous work executes.

Example

An organization admin can change a member role only after the backend confirms both the actor's current organization-admin permission and the target's membership in that same organization.

Common failures

  • Checking roles only in client routes.
  • Trusting client-supplied tenant identity.
  • Long-lived credentials without rotation/revocation.

Validation

Test anonymous, ordinary, admin, revoked, cross-tenant, expired-session, and background-job access paths; review audit and recovery behavior.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.