Skip to main content

Decide who may do what

When. Some operations are for everyone, others for a signed-in person; or the tenant must answer for the person, within their own scope.

Steps​

  1. Sort the operations: what anyone may do, what needs a signed-in person.
  2. Write the profiles. A profile is a condition on the identity (when) and the operations it is granted (grants, written <api>.<operationId>). A station that signs no one in has one: everyone: {when: "true", grants: [...]}. Grants add up.
  3. To sign a person in, declare a provider in station.identity.providers: mechanism: otp, via: tenant, send and check (two operations of the tenant, declared access: write), verifies (the name of the data proved) and type. check answers {"verified": true}.
  4. For the tenant to answer for the person, credential names the field of check's answer that holds their token, and auth.person: {provider: …} sends it on their calls.
  5. To restrict further: the permission guard keeps the choice of an item to some profiles; submit_guard.submitted_by: [{who: owner}] keeps the submit to the signed-in person who owns the room.

The example​

who-may-do-what.yaml
# Who may do what: everything is closed until a profile is granted it. Anyone may list the teams;
# a person who proved their e-mail with a one-time code (sent and checked by the tenant's own
# operations) may also read the timesheets, and the tenant answers for them with their own token.
# Replace api.example.com by the API.
station:
id: team-timesheets
name: Team Timesheets
identity:
providers:
email:
mechanism: otp
verifies: email
type: email
via: tenant
send: sendVerificationCode # the tenant's operation that sends the code
check: checkVerificationCode # the one that checks it: {"verified": true, "access_token": …}
credential: access_token # the field of that answer holding the person's token

global:
language: en
currency: EUR
locale: en-GB

domain:
domain_type: saas
entity_name: team
entity_name_plural: teams

voice:
tone: professional
persona: "an HR assistant who answers with figures, briefly"
rules:
- "Never state an hour that was not recorded: every figure comes from the tool."

apis:
- name: hr
openapi_url: https://api.example.com/openapi.json
base_url: https://api.example.com
operations:
- {id: listTeams, access: read}
- {id: getTimesheets, access: read}
- {id: sendVerificationCode, access: write} # writes, called by the sign-in only
- {id: checkVerificationCode, access: write}
auth:
type: none
person: {provider: email} # the signed-in person's token goes on their calls

profiles:
anyone:
when: "true"
grants: [hr.listTeams]
signed_in: # called before signing in, the surface asks for it
when: "$identity.authenticated"
grants: [hr.getTimesheets] # grants add up: they keep listTeams from `anyone`

skills:
- name: teams
cognitive:
objective: list the teams, to choose the one the question is about
invoke: {method: listTeams}

- name: timesheets
cognitive:
objective: give a team's timesheets for a week; it needs a signed-in person
params:
team: {type: text, set_by: [llm]}
invoke:
method: getTimesheets
args: {team: "$params.team"}

The pitfalls​

  • Everything is closed by default. A config that calls operations without profiles is refused, and so is an operation no profile is granted ("no profile is granted it").
  • Sign-in operations are not granted. Putting send or check in grants is refused: proving who you are is not a right.
  • when reads the identity only: $identity.authenticated, $identity.verified (with in: 'email' in $identity.verified), $identity.provider, $identity.type, or true. Roles, teams or organisations do not exist yet: refused. So is $identity.declared.
  • A profile no one can hold is refused ('phone' in $identity.verified with no provider that verifies: phone).
  • auth.person without credential on its provider is refused: there would be no token to send.
  • Only an explicit yes counts: an answer of check without verified: true means no.
  • The sign-in is asked for only when a skill is called. When an item is chosen and at the submit, a missing grant refuses (not_granted).
  • owner is the only who of submitted_by; another is refused at load.

What Core says, and the fix​

Each sentence below is Core's own, as it answers today (a test keeps them true):

  • "is an identity provider's own operation: proving who calls is not granted" — fix: take send and check out of every grants.
  • "which issues none (no credential)" — fix: name the field of check's answer that holds the person's token: credential: access_token.
  • "$identity.<field> has no sub-field" — fix: a role or a team cannot be read yet; open the operation to $identity.authenticated and let the tenant answer for the person (auth.person).

Reference: Profiles, The one-time code, The person's own token.