Managing Toolbelt Sessions

Toolbelt provides a client-side tool for access to the Aunsight platform. As part of its communication with the Aunsight platform services, Toolbelt manages access tokens obtained from the Aunsight identity service. These tokens serve as the authentication mechanism for requests to the platform, and can be obtained, stored, and renewed using specific Toolbelt commands. The present article describes how to manage Toolbelt sessions by logging in, viewing and renewing a token, and logging out. After reading this article, Toolbelt users will be able to authenticate and manage Toolbelt sessions using the command line interface.

Logging In

To initiate a session in the Toolbelt, type au2 login at the terminal and enter your username and password when prompted.

$ au2 login
email: [email protected]

Upon successful log-on, the Toolbelt will acquire a session token from the Aunsight platform services and display it in the terminal. Users do not need to do anything with this token, since it is automatically stored in the file location specified in the Toolbelt configuration. This token will provides access to the Aunsight platform for twenty-four hours or the user logs off. Users can either also extend the length of their session by renewing their token.

Displaying Information about the Current Session Token

Logging in to Aunsight obtains a token that is used to authenticate requests to the platform services. The au2 context token-info command displays information about this token and its expiration

$ au2 context token-info
Issued at Mon Feb 03 2020 10:58:44 GMT-0500 (EST)
Expires at Mon Feb 03 2020 10:58:44 GMT-0500 (EST)
Orginally issued at Mon Feb 03 2020 10:58:44 GMT-0500 (EST)
Expires in a day

Displaying the Current User's information

Once a session has been initiated, au2 context whoami will display information about the user associated with the current session.

$ au2 context whoami
│ firstname │ Benjamin                                │
│ lastname  │ Wright                                  │
│ email     │ [email protected]          │
│ id        │ 0221668b-58f1-4102-a8c5-3ad228edf54d    │
│ active    │ true                                    │

Renewing a Token

Session tokens expire twenty-four hours after their issue. After this, the Aunsight services will no longer respond to calls using the expired token, and users will need to acquire a new token by logging in again.

As a convenience, users can renew their token without re-entering credentials with the following command:

au2 context renew-token

This command will request a new token from the Aunsight platform services, granting an additional twenty-four hours to the current session time-out. This command can be used to keep alive a session that is about to expire.

Logging Out

If you wish to end a session before a token expires, simply log out of the current session.

au2 logout

This deletes the token stored in a temporary file (by default, /tmp/aunsight-token.json) requiring a new token before further API calls can be issued by the Toolbelt.