Unlatch GitHub

Connecting applications

An application that supports OpenID Connect sends people to Unlatch to sign in and gets back who they are. For services that don't support it, use forward authentication.

Adding an application

  1. In administration, open Applications, choose Add and give the application a name and a Client ID, such as grafana. Check Public client only for a mobile or browser app, which can't keep a secret.
  2. Copy the client secret into the application. Unlatch shows it only once; Issue a new secret replaces it, and the old one stops working at once.
  3. Under Redirect URIs, enter the address the application's documentation names. It must match what the application sends character for character.
  4. Under Access, choose Everyone or the groups whose members may use it.

The application then needs these values; most find everything from the issuer alone.

SettingValue
Issuerhttps://login.example.com
Discoveryhttps://login.example.com/.well-known/openid-configuration
Authorization endpointhttps://login.example.com/authorize
Token endpointhttps://login.example.com/token
Userinfo endpointhttps://login.example.com/userinfo
Sign-out endpointhttps://login.example.com/end-session
Scopesopenid profile email groups

What applications learn

The application gets what the scopes it asks for allow, in the ID token and from userinfo:

ScopeWhat the application gets
openidsub, a stable identifier of the account
profilename and preferred_username, the username
emailemail and email_verified, if the user has an address
groupsgroups, the names of the user's groups
offline_accessA refresh token, which works until the user's session ends

The first time someone signs in to an application, Unlatch asks them to allow this and remembers the answer. For your own applications, set Consent to Don't ask. A public client on the user's device is asked every time, because another program could pose as it.

Other settings

Example: Grafana

The redirect URI is https://grafana.example.com/login/generic_oauth. In grafana.ini:

[auth.generic_oauth]
enabled = true
name = Unlatch
client_id = grafana
client_secret = the secret from Unlatch
scopes = openid profile email groups
auth_url = https://login.example.com/authorize
token_url = https://login.example.com/token
api_url = https://login.example.com/userinfo
use_pkce = true
login_attribute_path = preferred_username
role_attribute_path = contains(groups[*], 'admins') && 'Admin' || 'Viewer'

The last line makes members of the group admins administrators in Grafana and everyone else viewers.