26.30. kych-client-management(1)#

26.30.1. Name#

kych-client-management - manage OAuth 2.0 clients of the KyCH gateway

26.30.2. Synopsis#

kych-client-management [-c CONFIG] [-L LEVEL] [-v] COMMAND [OPTIONS]

26.30.3. Description#

kych-client-management maintains the table of OAuth 2.0 clients that kych-oauth2-gateway(1) serves. It allows administrators to create, update, delete, list and synchronize client registrations.

This tool exists because the running gateway resolves clients from the database and never from the configuration file. The [client_*] sections of kych.conf(5) are only a declarative source for the sync command below; adding a section and restarting the gateway has no effect. A configuration file is nevertheless needed for every invocation, because the database connection string is read from it.

Client secrets are stored bcrypt-hashed and cannot be recovered, only replaced.

26.30.4. Global Options#

-c CONFIG | –config=CONFIG

Use the configuration file CONFIG. Without it the standard search path applies, ending at /etc/kych/kych.conf; see kych.conf(5).

-L LEVEL | –log=LEVEL

Set the logging verbosity: ERROR, WARN, INFO, DEBUG or TRACE, or the numbers 1 to 5. Defaults to INFO. This affects the diagnostics on standard error only; the output of the commands themselves goes to standard output regardless.

-v | –verbose

Also log what the libraries have to say, sqlx in particular, which is the way to see the statements this tool runs.

-h | –help

Print short help. Also accepted after a command, as in kych-client-management help create, for the options of that command.

-V | –version

Print version information and exit.

26.30.5. Commands#

26.30.5.1. list#

List all registered OAuth 2.0 clients, followed by the total count.

kych-client-management -c CONFIG list

26.30.5.2. show#

Show details of one OAuth 2.0 client. Fails if it does not exist.

kych-client-management -c CONFIG show CLIENT_ID

CLIENT_ID

The identifier of the client to display.

Both list and show report the internal UUID, the client identifier, a truncated prefix of the secret hash, the redirect URI allowlist, the vocabularies and profiles the client may use, and the creation and modification times. A client that has no vocabulary – one from before the configuration had vocabularies, not yet synchronized – cannot start a verification.

26.30.5.3. create#

Create a new OAuth 2.0 client.

kych-client-management -c CONFIG create [OPTIONS]

–client-id=CLIENT_ID

The unique identifier for the new client. Required.

–secret=SECRET

The client secret for authentication. Required. Stored hashed. Note that it is visible in the process list and in the shell history while this command runs.

–redirect-uri=URI

The OAuth 2.0 redirect URI for this client. Required. Several may be given as one comma-separated value; a redirect URI presented at authorization time must match one of them exactly.

–vocabularies=LIST

The vocabularies the client may use, as a list such as {swiyu} or {eupid, eupid-mdoc}; each must be enabled in the configuration’s VOCABULARIES. Required.

–profiles=LIST

The profiles the client may name in its scope, such as {kyc}; each must exist and cover one of the client’s vocabularies. Optional.

Which verifier serves the client, and which issuers it accepts, follow from the vocabularies, configured system-wide in kych.conf(5).

26.30.5.4. update#

Update an existing OAuth 2.0 client. At least one option must be provided; omitted fields keep their current value. The secret cannot be changed this way.

kych-client-management -c CONFIG update CLIENT_ID [OPTIONS]

CLIENT_ID

The identifier of the client to update.

–redirect-uri=URI

Update the OAuth 2.0 redirect URI allowlist.

–vocabularies=LIST

Replace the vocabularies the client may use.

–profiles=LIST

Replace the profiles the client may use.

The result is checked against the configuration as a whole, so changing the vocabularies may require changing the profiles in the same command.

26.30.5.5. purge#

Delete what the gateway no longer needs, once: the claims and the evidence of verifications whose client first fetched them more than PURGE_GRACE ago, and the sessions, authorization codes and access tokens that have expired. This is what kych-oauth2-gateway(1) does by itself every PURGE_INTERVAL; the command is for running it from cron, for instance with PURGE_INTERVAL = 0 s, so that data is deleted on time even while the gateway is down, or by hand. Running it while the gateway sweeps as well is harmless.

kych-client-management -c CONFIG purge

It prints what it did, as in purged the claims of 2 session(s); deleted 5 session(s), 0 code(s), 1 token(s). See kych.conf(5) for the rules.

26.30.5.6. delete#

Delete an OAuth 2.0 client.

kych-client-management -c CONFIG delete [OPTIONS] CLIENT_ID

CLIENT_ID

The identifier of the client to delete.

-y | –yes

Skip the confirmation prompt. Without it, the deletion must be confirmed by typing yes on standard input.

Warning

Deletion cascades in the database: all verification sessions of that client, and with them the stored credentials, authorization codes and access tokens, are removed.

26.30.5.7. sync#

Read every [client_*] section of the configuration file and bring the database in line with it: the redirect URIs, the vocabularies and the profiles. Sections whose client identifier is unknown are created; the rest are updated. The configuration is checked as a whole first, as the gateway checks it at start, so a section still carrying the per-client verifier options of earlier versions makes sync fail with the option’s name.

Run it after every upgrade that adds client options, and after every change to a [client_*] section; the gateway reads clients from the database only.

kych-client-management -c CONFIG sync [OPTIONS]

–prune

Remove clients from the database that are not present in the configuration file, with the same consequences as delete above.

Note

sync never rotates a secret: CLIENT_SECRET is read only when a client is first created, and editing it in the configuration file has no effect. To change a secret, delete the client and synchronize again, or recreate it with create.

26.30.6. Exit Status#

Zero on success. Non-zero if the configuration cannot be read, the database is unreachable, the named client does not exist, or a client identifier being created already exists.

26.30.7. Examples#

Register the clients described in the configuration file, then check the result:

$ kych-client-management -c /etc/kych/kych.conf sync
$ kych-client-management -c /etc/kych/kych.conf list

Register one client directly:

$ kych-client-management -c /etc/kych/kych.conf create \
    --client-id exchange-prod-01 \
    --secret SECRET \
    --redirect-uri https://exchange.example.com/kyc-proof/kych \
    --vocabularies '{swiyu}'

Let an existing client ask for the shipped kyc profile:

$ kych-client-management -c /etc/kych/kych.conf update exchange-prod-01 \
    --profiles '{kyc}'

Give an existing client a second redirect URI:

$ kych-client-management -c /etc/kych/kych.conf update exchange-prod-01 \
    --redirect-uri 'https://exchange.example.com/kyc-proof/kych,https://exchange.example.com/kyc-proof/kych2'

26.30.8. See Also#

kych-oauth2-gateway(1), kych.conf(5).

26.30.9. Bugs#

Report bugs by using https://bugs.taler.net/ or by sending electronic mail to <taler@gnu.org>.