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
- Sort the operations: what anyone may do, what needs a signed-in person.
- 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. - To sign a person in, declare a provider in
station.identity.providers:mechanism: otp,via: tenant,sendandcheck(two operations of the tenant, declaredaccess: write),verifies(the name of the data proved) andtype.checkanswers{"verified": true}. - For the tenant to answer for the person,
credentialnames the field ofcheck's answer that holds their token, andauth.person: {provider: …}sends it on their calls. - To restrict further: the
permissionguard 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
profilesis refused, and so is an operation no profile is granted ("no profile is granted it"). - Sign-in operations are not granted. Putting
sendorcheckingrantsis refused: proving who you are is not a right. whenreads the identity only:$identity.authenticated,$identity.verified(within:'email' in $identity.verified),$identity.provider,$identity.type, ortrue. Roles, teams or organisations do not exist yet: refused. So is$identity.declared.- A profile no one can hold is refused (
'phone' in $identity.verifiedwith no provider thatverifies: phone). auth.personwithoutcredentialon its provider is refused: there would be no token to send.- Only an explicit yes counts: an answer of
checkwithoutverified: truemeans 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). owneris the onlywhoofsubmitted_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
sendandcheckout of everygrants. - "which issues none (no
credential)" — fix: name the field ofcheck'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.authenticatedand let the tenant answer for the person (auth.person).
Reference: Profiles, The one-time code, The person's own token.