Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bringing your people in

A site is run by a handful of people: whoever answers for each question it asks, and whoever works each desk. This is how they get in, from nobody to everyone signed in at their own desk, without anyone handing out passwords or running an admin tool per person.

The idea in one line: the content says who is involved, and portal lets them in. A page names who is responsible for it, a directory is gated on a group, a desk may invite into groups. Portal reads that and does the rest.

Two ways to sign people in

people sign in withwho keeps the groupsyou set up
A provider you already haveVipps Login, Rauthy, a Kanidm shared with others: any OpenID providerportal itself (Memberships)one sign-in client
A Kanidm of the site’s ownthe Kanidm, with accounts portal makesKanidmKanidm, once (step 2 below)

The first is less to run. The content is the same either way, and which one a site uses is one variable (PEOPLE_BACKEND). The second makes the accounts too: someone with no way to sign in yet gets a one-time link to set a password or a passkey.

What you need

  • A content repo, and a portal instance running it (Operations has adding a site).
  • One of the two above.
  • Mail: mail: { from } in site.yaml, and gdo beside the site, its key named in DHD_KEYS (Operations). Without it people are still let in, but nobody hears about it.

1. Say who is involved, in the content

Four things in the content decide who needs to get in:

contentwhowhat they get
responsible: { name, contact } on a pagethe person answering for that questionthe box at the foot of the page to change it; on Kanidm, an account and a mail saying they are listed as responsible
responsible: { name, contact, group }a group answering for itnothing of its own: the group’s members have the page, and each may suggest changes to it
qualifies: board on a page or _section.yamlmembers of that groupthe pages and desks under it
invite: { group: treasurer } on a desk pagethe desk’s own groupthe right to bring people into treasurer

The desk whose group may invite into the most groups is the site’s most privileged one; for an association that is the board. Portal works that out from the content (see step 4).

2. Set up sign-in

A provider you already have

Make a client at the provider for the site: the authorization_code flow, the scopes openid profile email, and <PUBLIC_URL>/auth/callback as its redirect. Then portal’s environment:

variablevalue
OIDC_ISSUERthe provider’s issuer, exactly as its discovery document says it
OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRETthe client
PEOPLE_BACKENDmemberships
OIDC_EXTRA_SCOPESphoneNumber for Vipps, so a person is known by their number

That is all: whoever can sign in with the provider can sign in to the site, and what they see comes from the places portal keeps for them.

A Kanidm of the site’s own

Group names below are exactly the ones the content uses, with no prefix; that is only safe when the Kanidm serves this site alone. Portal needs four things from it, set up once as idm_admin:

K="kanidm -D idm_admin -H https://id.example.no"

# An onboarding account: may create people and issue a first password
# link, nothing more. pii_read lets an invite find someone who already
# has an account by their email instead of making a second one.
$K service-account create portal-onboarding "Portal onboarding" idm_admin
$K group add-members idm_people_on_boarding portal-onboarding
$K group add-members idm_people_pii_read portal-onboarding

# One group per `qualifies:` in the content, managed by that account:
# adding a member to a group takes the right to manage it.
for g in board treasurer traffic; do
  $K group create "$g" portal-onboarding
done

# The sign-in client. Everyone in this Kanidm may sign in; what they
# see comes from their groups, in the `groups` claim.
$K system oauth2 create portal "My site" https://site.example.no
$K system oauth2 add-redirect-url portal https://site.example.no/auth/callback
$K system oauth2 update-scope-map portal idm_all_persons openid profile email
for g in board treasurer traffic; do
  $K system oauth2 update-claim-map portal groups "$g" "$g"
done
$K system oauth2 update-claim-map-join portal groups array

# The onboarding token, read-write, shown once: into portal's env.
$K service-account api-token generate portal-onboarding portal --readwrite

Then portal’s environment:

variablevalue
KANIDM_URLhttps://id.example.no
OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRETthe client above (show-basic-secret)
KANIDM_API_TOKENthe onboarding token

3. Name the first person

Someone has to be first: every later person is invited from a desk, and before anyone is in, there is no desk anyone can open.

variablevalue
SEED_ADMIN_EMAILthe first person’s address (or SEED_ADMIN_PHONE, their number, with a provider that verifies numbers)
SEED_ADMIN_NAMEtheir name, as it should appear (optional)
SEED_GROUPa group to put them in, if not the most privileged one (optional)
RESPONSIBLE_GROUPa group every responsible person joins, e.g. editors (optional)

4. Start portal

At start, portal:

  1. Invites the first person into SEED_GROUP, or the most privileged group, and mails them: the one-time link on Kanidm, the way to sign in otherwise. Once: it is remembered in the portal_seed bucket, so restarts and upgrades never send a second link.
  2. On Kanidm, makes an account for everyone named responsible who has none, and mails them that they are listed as responsible for asking those questions, with their link. With RESPONSIBLE_GROUP they all join it; someone who already had an account is added without a mail. On memberships they get a place in RESPONSIBLE_GROUP, where one is named.

The two run side by side. Kanidm may still be starting beside portal, so each is tried again a minute apart, up to twenty times. The log says what happened, per person.

The second happens again whenever the content changes, so a new page naming a new person sets them up without a restart. And it works both ways: someone the content has stopped naming leaves RESPONSIBLE_GROUP in the same pass, and with it whatever else that group opens. Only if portal is who put them there - a person who was in the group before is left in it - and their account stays, since it is theirs.

5. The rest come in from the desks

From here nobody sets anyone up by hand:

  • At a desk, whoever may invite fills in a name and an address. Portal holds them a place in the group and mails them: a one-time link on Kanidm, the way to sign in otherwise.
  • A decision can be the invitation. A state with grants: group in aggregates.yaml puts the person a case is about into that group when the case arrives there - an approved committee application that is the membership.
  • A new page with a new responsible person gets them an account when the page goes live.

An invite that nobody used

A link lives a day. On a site with Kanidm as the people backend every invite - a desk’s, and the ones portal made at start for someone new - is a case in portal_invites, and keeps itself current. (On memberships a desk’s invite into a group is a place, its case in portal_memberships; only the ones made at start and an invite with no group are here. See Memberships.)

statemeanshow it gets there
openthe link is waitingthe invite was sent, or sent again
donethe person is inthey signed in to the site; or a desk says so
expiredthe link ran out unuseda sweep, every ten minutes

A desk that lists the bucket offers the way back with a transition from expired to open. Pressing it makes a fresh link and mails it, unless they have found a way to sign in meanwhile. Inviting again someone whose account, by address, has nothing to sign in with does the same, and that link is in the mail only, not on the record, since the account may already hold places:

resource:
  source: { bucket: portal_invites }
  requires_group: board
  transitions:
    - { from: open, to: done, label: Is in }
    - { from: expired, to: open, label: Send again }
    - { from: expired, to: done, label: Is in }

6. What the people who ask the questions can do

Signed in, a person a page names as responsible sees a card at the foot of their own pages to suggest a change. The server checks it is really them.

On an instance that may change the content repo (EDIT_GITEA_TOKEN), the card is a conversation: they say what should read differently, see exactly what would change, and it is live on their yes. A change to how the work goes, beyond the words on their page, is drafted the same way and handed to whoever maintains the site (Training).

Without it, the card is a plain form: the suggestion is mailed to the site’s inbox with them as reply-to, so answering it answers them.

It is also a case, in the built-in portal_edit_suggestions bucket, so it does not depend on somebody reading that inbox. Give a desk the list, and whoever sits there takes it up and settles it:

resource:
  source: { bucket: portal_edit_suggestions }
  requires_group: board
  transitions:
    - { from: open, to: discussed, label: Looking at it }
    - { from: open, to: done, label: Changed }
    - { from: open, to: declined, label: Will not change }
    - { from: discussed, to: done, label: Changed }
    - { from: discussed, to: declined, label: Will not change }

The person who suggested it is mailed at each move, in the site’s language, and the card on their page lists what they have sent and where each one stands. A content repo that declares the bucket itself in aggregates.yaml, with a mail: on a state, sends that instead.

A group can be the way into other tools too: a second OAuth2 client in Kanidm, scoped to the group alone, lets its members sign in to a Gitea (say) with the same account.

When it does not work

what you seewhy
an invite fails with 404 adding to a groupthe group is not managed by portal-onboarding: group set-entry-manager <group> portal-onboarding
Item not found setting the login page’s name or logothose are system settings only admin may change, not idm_admin - or the CLI and server versions differ
accounts are made but nobody is mailedsite.yaml has no mail.from, or gdo is not running beside the site with its key in DHD_KEYS
someone responsible never got a mailthey can already sign in (they are only added to RESPONSIBLE_GROUP), or their contact is not an email address
someone invited again got no linkthey have something to sign in with, or their address is not on the account that has the name: only an account found by its address, with nothing to sign in with, gets a new link
“send again” is not on the deskthe list has no { from: expired, to: open } transition, or the content declares portal_invites itself without an expired state
someone left a page and is still in RESPONSIBLE_GROUPthey were in the group before portal added them, so it is not portal’s to undo
the first person was invited twiceit cannot be, per address and group; changing SEED_ADMIN_EMAIL or SEED_GROUP invites the new pair