Skip to content

Docs

Permissions

Groups, permission strings and the can() check that guards menus, pages and API routes of OSAGI Console, and how to manage access.

Rights are granted to groups, and a user gets the union of the rights of all their groups. The same can() from lib/auth/perms.ts decides on the server, in the API routes and in the menu.

Permission strings

A right is a string module:action:scope, for example requests:view:own or sla:view:all.

PartValues
Modulerequests, support, chat, sla, workload, leads, marketing, docs, access, and ops for Operations
Actionview reads, edit creates and changes records, manage works with everyone's records and the module settings
Scopeown: records of the user; all: every record

How can() reads them:

  • manage includes edit, and edit includes view.
  • all covers a check for own; a check without a scope is met by any scope (menus and buttons use it).
  • An owner (*) may do everything.
  • Rows with an unknown module, action or scope are dropped, so a typo never widens access.

What each action opens

Modulevieweditmanage
requestsThe journal and request cards: own for the user's requests, all for everyone's; approvers named on the Access screen decide on the requests they can seeCreate requests and draftsWith all: change the status of any request
supportThe user's ticketsOpen tickets, write messages, add attachments; with all: the team queueSame as edit
chatThe chat in the menuTalk to the assistant, keep sessions and assistant memoryOther people's sessions and the Assistants screen (/consultants)
sla, workload, leadsWith all and the open section: the report screen and its APINo extra actionsNo extra actions
marketingWith all and the open section: the Marketing screenCreate tasks and act on news and findsSame as edit
docsRead the docs, search and recent changesSame as viewWith all: edit pages and review AI suggestions
accessNothing on its ownNothing on its ownWith all: the Access screen
opsWith all and the open Operations section: every Operations screen and its APIWith all: switch alert rules, acknowledge alerts, run endpoint actionsWith all: decommission endpoints

The AI cost of a request is shown to its author and to people with access:manage:all or requests:manage:all; for everyone else the server leaves it out.

Sections

A section is a console screen opened for a group, separate from the data right: the assistant may need a module's data for a user who should not see its screen. A report page opens only when both hold: the user has <module>:view:all AND the section is enabled for one of their groups (screenAllowedFor() in lib/auth/screens.ts). An owner sees every section.

Where the checks run

CheckUsed by
requireUser(req, { module, action, scope })Every page and route handler: 401 without a session, 403 without the right
requireModuleApi(req, module)Report APIs: the data right AND the open section
guardModulePage(headers, module)Report pages: sends to sign-in or shows a "no access" screen
runAsUser(need, fn)Server actions, such as saving a docs page
config/nav.ts and lib/shell/nav.tsThe menu, filtered with the same can()

Warning

Hiding a menu item is not protection. Every page, route handler and server action checks again on the server.

Managing access

The Access screen (/access, needs access:manage) edits groups, their rights in a matrix, the sections they open and the approvers of requests.

The demo user is an owner, so every screen is open. To see the console as a restricted user, return a smaller set from permsOf() in lib/auth/identity.kit.ts:

ts
import { mergePerms } from "./perms";
const ANALYST = mergePerms(  [    { action: "edit", module: "requests", scope: "own" },    { action: "view", module: "sla", scope: "all" },  ],  false,  ["requests", "sla"]);

With a real loader, wrap it in createPermsCache(): rights are cached for 60 seconds, and invalidatePerms() drops the cache after a change.