Skip to content
Sign-In and the API

Sign-In and the API

gpsu always serves the web UI, the JSON API, and browser sign-in.

Web UI and API

GPSU_PUBLIC_URL=https://gpsu.example.com GPSU_TRUSTED_PROXIES=10.0.0.0/8 gpsu serve
VariableFlagDefaultDescription
GPSU_PUBLIC_URL--public-urlThe URL browsers use to reach gpsu. gpsu needs it. gpsu answers only at its host.
GPSU_LISTEN--listen:8080The address and port the web UI and the API listen on
GPSU_TRUSTED_PROXIES--trusted-proxiesComma-separated proxy addresses whose X-Forwarded-For header names the client

Ways to sign in

Users sign in two ways:

MethodNeedsManaged in
Local accountsNothingUsers
Identity providerAn OpenID Connect providerSettings › Sign-in

Identity provider

gpsu keeps the identity provider in its database. Admins manage it from any of these:

InterfaceWhere
Web UISettings › Sign-in
CLIgpsu provider
API/api/v1/provider

Changes apply at once.

Register gpsu at the provider with two clients:

  • a confidential web client with the redirect URI <GPSU_PUBLIC_URL>/auth/callback
  • a public command-line client with the device code flow enabled
ItemDetail
nameLabels the provider’s button beside the local password form
Client secretEncrypted with the seal key, or kept in Vault with --client-secret-vault. gpsu never shows a saved secret.
Validationgpsu checks that each issuer responds before it saves a change.
Roles from groupsSettings › Sign-in maps the provider’s groups to roles. A user gets the highest role their groups map to at their next sign-in.

Warning

Changing the issuer or removing the provider signs out the provider’s users. It also revokes their tokens. A new provider could otherwise issue the same user ID to someone else. Local accounts stay signed in.

The web UI asks you to confirm. gpsu provider set with a new issuer and gpsu provider remove both need --yes.

Local accounts

Users with a local account sign in at /auth/login with a username and password.

  • Local sign-in is always enabled.
  • Local accounts suit a homelab without an identity provider.
  • Local accounts let an admin sign in while the provider is down.
ItemDetail
UsernameLowercase letters, digits, ., -, and _
User IDlocal:<username>. No identity provider can claim it.
RoleThe one set on the account’s page
PasswordAt least 15 characters
Stored asAn Argon2id hash. Restoring a backup keeps each account’s password.

Set and reset passwords

ActionWhoResult
Add an accountAn admin, on UsersA one-time setup link, shown once and valid for 24 hours. The user opens it and sets a password.
Create a reset linkAn admin, on the user’s pageA one-time reset link, valid for 24 hours. The old password works until someone uses the link. Using it ends all of the user’s other logins and tokens.
Change your passwordThe user, on My accountThe user’s other logins end.

gpsu stores only a SHA-256 hash of each link.

Second factors

A local account can add an authenticator app or a passkey. gpsu then asks for a code from the app or the passkey after the password.

AccountSecond factor
AdminRequired. An admin without an app or a passkey adds one at their next sign-in.
Viewer or operatorOptional. Required when an admin enables Require for every local account in the sign-in limits.
Identity provider userNever asked. The provider handles its own second factor.

Add the app

Select Add authenticator app on My account, or follow the prompt at sign-in. The prompt also offers Add a passkey instead. Scan the QR code with an authenticator app such as Aegis or 1Password. You can type the key into the app instead.

Confirm it

Enter the app’s current code. On My account, enter your current password too. A wrong code keeps the same QR code for 10 minutes.

Save the recovery codes

gpsu shows ten recovery codes once. Keep them somewhere safe.

ItemDetail
AppAny app that reads otpauth:// QR codes. Codes have six digits and change every 30 seconds.
CodeEach code works once. gpsu accepts the code before and after the current one to allow for clock drift.
Recovery codeSigns in once in place of a code. Case, spaces, and the dash don’t matter.
App’s keyEncrypted with the seal key
Recovery codesStored as SHA-256 hashes
Time to finish10 minutes after the password. After that, sign in again.

My account shows the app and how many recovery codes are left. Each change asks for a code from the app or a recovery code:

ActionEffect
New recovery codesShows ten new codes once. The old codes stop working.
Remove appgpsu stops asking for a code. The recovery codes stop working unless a passkey remains. An account that must have a second factor adds a new one at its next sign-in.

An admin can remove the second factors of a user who lost their devices and their recovery codes. They do it with Remove second factors on the user’s page under Users. It removes the user’s app, passkeys, and recovery codes.

  • It needs no code. The admin confirms first.

  • The user keeps their password, logins, and tokens.

  • An admin removes their own second factors on My account, which asks for a code.

  • Only the owner can remove the owner’s second factors. An owner who lost theirs can reset their access.

  • Wrong codes count with wrong passwords toward the sign-in limits. A right password doesn’t clear the count while a code follows.

  • The audit log records each app added, each set of new recovery codes, each recovery code used, and each removal.

  • Without a seal key, gpsu asks no one to add an app.

Passkeys

A passkey signs in with a device’s fingerprint, face, or PIN. My account lists each passkey and adds, renames, and removes them.

Sign-inWhat the passkey does
Sign in with a passkey on the sign-in pageSigns in alone. The device’s PIN or biometric makes it both factors.
Use a passkey after the passwordStands in for the code from the app
The prompt for a second factorAdd a passkey instead adds one in place of an app
ActionAsks for
Add passkeyA name and your current password. Your browser then asks your device to make the passkey.
RenameThe new name
RemoveA code from your app or a recovery code
ItemDetail
Second factorA passkey counts as one. The first passkey of an account without an app brings ten recovery codes.
Name1 to 64 characters, such as the device it lives on
Stored asThe credential record, encrypted with the seal key, under a random user handle
ScriptAdding a passkey needs JavaScript. gpsu bundles the SimpleWebAuthn browser library for it.

Important

Passkeys belong to the host of GPSU_PUBLIC_URL. That host must be a name, such as gpsu.example.com. An IP address can’t have passkeys. A different host later can’t use the passkeys made for the old one.

  • Removing a passkey in gpsu doesn’t remove it from the device. Remove it there too.
  • A passkey sign-in signs in only to an account that still has a password. A password reset doesn’t remove the account’s passkeys.
  • The audit log records each passkey added and removed.

The owner

One admin owns gpsu. The owner always has a local password. That lets them sign in while the identity provider is down.

Other admins can’t do any of these to the owner:

  • change their role
  • disable them
  • create a reset link for them
  • remove their authenticator app
  • revoke their logins or tokens

First owner

When gpsu starts without an owner:

Eligible adminsWhat happens
Exactly one enabled admin with a local passwordThat admin becomes the owner.
None, or more than onegpsu writes a setup code to its log.

Until setup is done, the sign-in page shows Set up gpsu. Enter the code there to create the owner’s admin account.

Each start writes a new code. The old code stops working.

Hand over ownership

The owner transfers ownership from another admin’s page under Users. The API does the same through POST /api/v1/users/{subject}/owner. That route needs a browser session.

  • The new owner must be an enabled admin with a local password.
  • gpsu refuses to restore a backup whose owner isn’t an enabled admin with a local password.

Reset a lost owner password or app

Run this on gpsu’s host:

gpsu owner reset

In a container, run it there. The image keeps gpsu at /gpsu:

docker compose exec gpsu /gpsu owner reset
  • It reads the same startup settings and database as gpsu serve. gpsu serve can keep running.
  • It enables the owner and gives them the admin role.
  • It removes the owner’s authenticator app, passkeys, and recovery codes. The owner adds a new second factor at their next sign-in.
  • It prints a one-time link that sets a new password. The link works for 24 hours.
  • Using the link signs out the owner’s other logins and tokens.
  • The audit log records the reset.
  • It never creates or upgrades a database.
  • If gpsu has no owner yet, it tells you to use the setup code from gpsu’s log.

Sign-in limits

Admins set how long a browser stays signed in, how failed sign-ins slow down, and who needs a second factor. They do it under Settings › Sign-in or at /api/v1/settings/sign-in-limits. A limit left blank uses its default.

LimitDefaultRangeEffect
Idle timeout12h5m to 720hSigns out a browser unused this long
Session length168hthe idle timeout to 2160hSigns out a browser this long after it signs in
Failures before a wait51 to 20Failed sign-ins in a row before a username waits
First wait30s1s to 10mThe first wait. It doubles with each later failure.
Longest wait15mthe first wait to 1hThe longest a wait grows
Require for every local accountDisabledEnabled or DisabledEvery local account adds an authenticator app at its next sign-in. Admins always need one.
  • A browser login ends at whichever comes first: the idle timeout after its last use, or the session length after it began.
  • A shorter limit signs out at once every browser past its new end.
  • Command-line logins and API tokens keep their own expiry.

With the defaults, failed sign-ins slow down like this:

Failures in a rowWait before the next attempt
1 to 4None
530 seconds
Each after thatDouble the last wait, up to 15 minutes
  • Unknown usernames wait the same way and take just as long to refuse. That hides which usernames exist.
  • The log names a refused username only when it belongs to an account. People sometimes type a password into the username field.

Roles

gpsu records each user at their first browser sign-in. Their groups set their role. See Roles from groups.

RoleCan
ViewerSee status and history
OperatorEverything a viewer can, plus set overrides
AdminEverything an operator can, plus manage servers, settings, and users
  • An admin can set a different role for a user. That role takes precedence over their groups.
  • An admin can disable a user.
  • Every change applies to the user’s next request.
  • gpsu refuses any change that would leave no enabled admin.

Capabilities

Each role also has capabilities. Two examples are building dashboards and creating API tokens. Admins change the capabilities of viewers and operators in Settings › Access or at /api/v1/access. Admins always have every capability.

RoleStarts with
ViewerShared dashboards. Charts reach back 24 hours.
OperatorEverything a viewer has, plus their own dashboards. Charts reach back 30 days.
AdminEvery capability

gpsu checks capabilities on every request. The API refuses whatever the web UI hides.

Command line and API tokens

WhoSigns in the command line with
Identity provider usersgpsu login and the device code flow. They must sign in with a browser once first.
Local account usersA personal API token in GPSU_TOKEN

Viewers and operators can create personal API tokens only when an admin grants the capability. A token acts this way:

Token owner’s roleToken can
Viewer or operatorOnly read, unless an admin lets it act with the owner’s role
AdminAct with the admin role
  • gpsu shows the token once.
  • A token expires within a year.
  • A token can’t create tokens or change users.

My account lists each of your logins. You can end any of them. Sign out everywhere ends every login and token issued before you select it.

Overrides

Settings › Defaults sets:

SettingDefaultAccepts
Maximum duration24 hours1 hour to 7 days

It also sets:

  • the durations the override form offers
  • the lifetimes the token form offers
  • how close to expiry a token is highlighted