Skip to content

Managing clientids

Deva Kumar edited this page Sep 17, 2020 · 11 revisions

registerclient

Application to manage clientids. The application runs as a cli. It can be run in interactive mode or non-interactive(batch) mode. The user of this app must have admin rights.


Quick start


Do the following in any shell:

npx @sassoftware/registerclient --host=Url-to-viya-server --ttl=ttl_in-days

ex:
npx @sassoftware/registerclient --host=http://viya.unx.brilliant.sas.com --ttl=1

On prompt (>) enter

logon

Then respond to request for userid and password.

Once you are logged on issue "help" command to see what is possible.

Web Applications

Recommend that you use authorization_code flow for web applications. This will allow your application to use VA-SDK.

Here is an example;

add viyademo -t authorization_code -s secret -r http://localhost:8080/viyademo,http://localhost:8080/viyaapp,https://localhost/viyademo,https://localhost/viyaapp

Non-web applications

Create password flow clientids

Here is an example:

add mycli -t password -s myclisecret

Advanced Usage


Create an env file ( call it register.env) with the following content

VIYA_SERVER=http://<your viyaserver>
AUTHTYPE=password
CLIENTID=sas.ec or a valid clientid( appears that sas.ec is shipped as a default clientid)
CLIENTSECRET=

Interactive mode


Start the interactive session with this command:

npx @sassoftware/registerclient --env <your-env-file>

This will start an interactive session where you can issue commands. Use the exit command to end the session. Enter the following command:

logon

You will be prompted for your userid and password. Once you are logged on you can issue the commands discussed below.

List of commands

  • logon - logon on to Viya server. You will be prompted for userid and password
  • list <all> - list current user-defined clientids. Use all option to additionally list system clientids
  • del clientid - delete the specified clientid( always returns 404 but work - no idea why)
  • add clientid < options > - add a new clientid

Options for the add command

  • -t == grant type == typically one of these: password | implicit | authorization_code)
  • -s == secret whatever you want(valid for password and authorization_code)
  • -r == redirect_uri == valid for implicit and authorization_code(if multiple redirects separate them by comma(,))

Examples

  1. Create a password flow clientid

    • add raf -t password -s raf
  2. Create an implicit flow clientid

  3. Create a authorization_code flow clientid

  4. list clientids including all SAS microservices clientids

    • list all
  5. list user clientids

    • list
  6. delete a specific client

    • del appc

Batch mode


This mode is useful when you want to run these commands as part of some process. I use them to setup all my clientids when I am configuring a new server so that all my apps can run on it.

Create a version of the register.env file with two additional keys - USER and PASSWORD

VIYA_SERVER=http://<your viyaserver>
AUTHTYPE=password
CLIENTID=sas.ec or a valid clientid( appears that sas.ec is shipped as a default clientid)
CLIENTSECRET=
USER=<username>
PASSWORD=<password>

Run the following command

npx @sassoftware/registerclient --file yourcmdfile --env <your-env-file>

The cmd file contains a list of the commands(see below). They are executed in order.

list
add app1 -t implicit -r http://localhost:5000/app1
add app2 -t authorization_code -s mysecret -r http://localhost:5000/viyaapp
list

Notes

The current configuration for all clientids is shown below:

scope: ['openid', '*'],
resource_ids: 'none',
autoapprove: true,
access_token_validity: 86400,
'use-session': true

This can be changed with the config command

config <path to your config file>

Install


This is only required if you want the cli to be installed in your local machine. Under normal circumstances this might not be necessary.

npm install -g @sassoftware/registerclient

This installs the cli as a global command

Clone this wiki locally