MyOwnPKI documentation Source on GitHub

Users, roles, second factor and API tokens

Every person signs in with a password and a second factor, and the role decides what they may do after that. This guide covers the roles, the second factor, API tokens and the limits that apply to them.

When to use this

The Users and roles page: two users with their roles and second-factor state

Roles and permissions

A user has roles per tenant, and a role can be limited to one CA. There are three tenant roles and one instance-wide flag.

Role May do
viewer Read CAs, certificates and CRL status. Cannot read the audit log.
operator Everything a viewer may, plus issue and renew certificates, revoke certificates, download server-generated keys, request a renewal for an agent deployment, and scan a TLS endpoint that is already entered
admin Everything an operator may, plus manage CAs and upload the offline root’s CRL, change tenant settings, manage agents and the agent enrollment mode, test notifications, manage TLS endpoints, and read the tenant audit log
instance admin A separate flag, not a tenant role: unseal and seal the server, and manage users. It gives no rights inside a tenant.

The permissions are checked inside the CA engine and the key ring, so the web UI, the API, ACME and the agent cannot bypass them.

Step-up. These actions ask for a fresh second factor even in a signed-in session: revoking a certificate, downloading a key, changing CAs, uploading a CRL, managing users, managing agents, and switching the agent enrollment mode. The confirmation stays valid for 5 minutes by default; an admin chooses 5, 10, 15, 30 or 60 in Administration → Tenant settings (operations guide §4).

1. Sign-in and the second factor

2. Add a user

You need the instance admin flag, and a fresh second factor.

  1. Open Administration → Users and roles and choose New user.
  2. Enter a user name (lower case a-z, 0-9, ., _, @, -), an initial password, a role and its scope (the whole tenant, or one CA).
  3. The next page shows the authenticator link, the secret and the recovery codes once. Give them to the user over a channel other than the one that carries the password.
  4. The user signs in and confirms the secret with a first code. Until then the list says TOTP (not confirmed yet).

Users are never deleted, because their ID is in the audit log. You disable them instead, which ends every session. Nobody can disable themselves, and the last active instance admin and tenant admin always stay.

3. Add a second admin

  1. Create the user as above with the role admin for the whole tenant.
  2. Tick Instance admin if this person should also unseal the server and manage users. Roles and the instance flag are independent: the tenant role runs the PKI, the flag runs the server and the users.
  3. Let them sign in once and confirm the authenticator.

4. Lost phone, locked out

Situation What to do
The user is locked out Wait 15 minutes, or an instance admin chooses Unlock now on the user’s page, or myownpki user unlock NAME
The phone is lost, recovery codes exist The user types a recovery code instead of the TOTP code, then makes a new authenticator under My account
The phone is lost, no recovery code At the server: myownpki user reset-2fa NAME. It needs the unseal passphrase, or --recovery-key. The user confirms the new secret at the next sign-in.

New recovery codes: My account → Recovery codes. The old ones stop working.

5. API tokens

A token is for a script. Sign in, open My account, and under New API token give it a name, a role with its scope and a validity of 1 to 366 days. Creating a token needs a fresh second factor.

Give each script its own token with the smallest role. See REST API for the complete list.

Check it worked

When it fails

Next steps