Machine clients
Under Applications → Application tokens live the ways in that belong to no person. Anybody who wants a program to run against the MNC's API creates a client here instead of handing the program a person's password.
What a client is for
Programs that reach the API without a user need a client of this kind: the nightly export, a reporting job, a monitor that checks every five minutes whether the base stations are still sending.
A machine client is an account without a person. It has a client ID, a secret and assignments — but no email address, no password and no second factor, because nobody is standing in front of it to confirm anything.
Why not simply create a user account for it? Three reasons, each sufficient on its own:
- A user account carries a person's password. Giving it to a program means giving it away.
- A user account disappears with the person. The nightly export then fails on the day somebody resigns.
- In the log the person's name appears instead of the program's — and the question "who was that?" has then been answered wrongly.
A client signs in with client credentials: the program sends client ID and secret to the token endpoint and receives a time-limited access token in return, which it then uses against the API.
POST https://<identity-provider>/connect/token
grant_type=client_credentials
client_id=<client ID>
client_secret=<secret>
scope=<scope>
Client ID, secret, token endpoint and scope are shown in the panel right after creation — all four values a program needs, in one place. Scope is already in the form the token endpoint expects: the client's scopes, separated by blanks.
Roles
A client carries no roles of its own any more; what it may do are its assignments, as for a user (see roles and assignments). The dialog offers the template — None, Viewer, Operator or Administrator, with Operator pre-selected — and it is given to the client ID as an assignment once the client exists. It should get only what it actually needs: an export that reads measurements does with Viewer. Finer choices, such as a role of your own, are made under Assignments. Only someone who may give roles sees the template.
Scopes
The roles say what a client may do; the scopes say what for it gets a token. A scope stands for
an API — the resource the token is issued for. A token for the scope mnc-api opens the MNC's API
and no other.
The dialog offers exactly the scopes the Identity Provider may give a client, with the intended one
already ticked. In an MNC installation that is one, mnc-api for the resource noritec-mnc; an
installation that protects further APIs lists them here as well. At most ten scopes per client, at
least one. The list's Scopes column shows per client what it can get tokens for — beside the assignments,
the other half of the question "who may do what?".
Creating one
The dialog asks for a name, the template and the scopes. The name serves recognition in this list only; it has no technical meaning, but it should say which program is meant — "Nightly report run" answers a question in a year's time that "Token 3" leaves open.
The client ID is generated by the Identity Provider itself.
Creating one takes a sign-in no more than a few minutes old — like everything that gives access in the administration (see users → recent sign-in): the secret opens the API far beyond the session it was created in. If the sign-in is older, the surface leads through the sign-in page, returns and opens the dialog again; name, template and scopes are chosen anew. Revoking does not take one.
The secret
After creation a panel appears above the list with client ID, secret, token endpoint and scope. That panel is the only moment the secret exists in readable form at all.
The Identity Provider stores only a hash of it — a fingerprint from which the secret cannot be computed back. It can check whether a secret presented at sign-in matches that fingerprint, but it cannot recite it a second time. There is therefore nothing a later click could show, which makes this panel not a detail of the interface but the only thing that can be offered.
What to do in that moment:
- Copy the secret and write it where the program reads its credentials — into the configuration, the secrets store, the service's environment variables.
- Take the client ID, the token endpoint and the scope as well; the secret is useless without them.
- Only then press Kept it, hide.
Whoever closes the panel without having taken the secret has to create the client again. A new client gets a new client ID, and that has to be carried into the program too.
A secret does not belong in a ticket, in a chat message or in a repository. Putting it in any of the three hands it to everybody reading along there.
Revoking
Revoke takes away the client's ability to obtain new access tokens. Tokens already issued stay valid until they expire — they are short-lived, but not dead in the same second. A revocation takes full effect once the last token issued has expired.
Revoking is final: there is no switching back, and the secret of a revoked client does not become valid again. A program that is to keep running gets a new client.
See also
- Users — the accounts with a person behind them
- Your account — profile, security and sign-ins