Permissions and access control
Inspect effective grants and administer custom roles using a personal key.
Use auth.getContext() to inspect the authenticated key without product grants. Read the permission catalog with ac:read. For organization roles, use a bound personal key with the applicable access-control permissions.
const context = await nirmos.auth.getContext();
console.log(context.organizationId, context.keyType, context.permissions);
const catalog = await nirmos.permissions.list();
console.log(catalog.map(permission => permission.key));Create a limited role
This mutation needs ac:create and cannot delegate beyond your own permissions:
const context = await nirmos.auth.getContext();
if (context.keyType !== "user" || !context.organizationId) throw new Error("Use a personal key");
const role = await nirmos.organizations.roles.create(context.organizationId, {
role: "prompt_reader", permission: { prompt: ["read"] },
});
console.log(role.id);Assign roles through organizations.members.assignRoles with member:update. Multiple assigned roles contribute a union of grants. Built-in roles cannot be edited or deleted; custom names are immutable, and assigned roles cannot be deleted.
Grants authorize resource/action operations, while organization ownership checks restrict resource IDs. There is no supported per-item policy system exposed by these methods. Your application remains responsible for end-user authorization before using a service key.
Permission concepts · Organizations and members · Role method contracts