Authentication and access control
For quick getting-started (local-playground) session and in-depth overview, please refer to:
Note: AuthN is currently in beta.
Table of contents
- User Account and Access management
- Token management
- Command List
- Register new user
- Update user
- Unregister existing user
- List registered users
- Add a new role
- List existing roles
- Log in to AIS cluster
- Log out
- Register new cluster
- Update existing cluster
- Unregister existing cluster
- List registered clusters
- Show AuthN server configuration
- Change AuthN server configuration
User Account and Access management
AuthN is an AIS authorization server that can be deployed to manage user access to one or more AIS clusters.
All commands (except logout) send requests to AuthN URL defined in the AIS CLI configuration file.
Configuration can be overridden with environment variable AIS_AUTHN_URL, e.g., AIS_AUTHN_URL=http://10.0.0.20:52001 ais auth add ....
The CLI provides an easy way to manage users, and to grant and revoke access permissions.
Only users with Admin role can manage the AuthN server.
Every request to AuthN, except login and logout, requires a token.
The token is generated by the server after the user successfully logs in.
CLI automatically saves the received token to user’s configuration directory and attaches it to every request.
When a token is revoked, AuthN notifies registered clusters, so that they update their blacklists.
Token management
Generate a token for CLI
After successful login, the CLI saves the generated token to the user’s configuration directory for future use and automatically passes it with every request to AuthN. For convenience, the CLI prints out the generated token so it can be copied and used with other clients.
Generate a token to a file
The CLI supports loading a token from a custom location.
One possible usage is imitating the Linux sudo command:
- A user logs into the AIStore cluster as an Admin and saves the token to some location.
- The user logs into AIStore as a regular user with default options. (A regular user’s requests would then use that last generated token for all requests).
- When elevated privileges are needed, the user can specify the path to the admin token.
Revoke a token
When a user’s token is compromised, the token should be revoked:
Command List
Register new user
ais auth add user [-p USER_PASS] USER_NAME [ROLE [ROLE...]]
Register a user and assign a list of roles to the user.
If the list of roles is not provided, the new user does not have any permissions.
Bucket access does not necessarily require creating a role. Instead, admin can register a user with an empty role and grant permissions to the required buckets.
Examples
Update user
ais auth update user [-p USER_PASS] USER_NAME [ROLE [ROLE...]]
Updates user password and list of roles. If the role list is omitted, the current
user role remains unchanged.
Changing the role for the built-in account admin is forbidden.
Unregister existing user
ais auth rm user USER_NAME
Remove an existing user. The built-in account admin cannot be removed.
List registered users
ais auth show user [USER [-v]]
Displays the list of registered users.
By default, the user is displayed in short mode.
Option -v prints detailed info:
Add a new role
ais auth add role ROLE_ID PERMISSION [PERMISSION...] [--flags]
Creates a role and grants the list of permissions to the role.
If only --cluster is defined, the permissions are used as default ones to access every bucket in the cluster.
Note:
- Flag
--bucketalways requires--clusterto be defined. PERMISSIONcan be a single compound permission (one ofro,rw,su) or a specific access permission.
Examples:
List existing roles
ais auth show role [ROLE]
Displays existing roles in alphabetical order.
Flags:
Note: some roles include “global” permissions - it is roles which are not bound to all clusters.
You can create such role by omitting --cluster flag while adding or updating a role.
To list “global” roles, pass a list which contains an empty cluster ID.
List that contains only “global” cluster ID is ",". E.g, ais auth show role --cluster=,.
By default, the role is displayed in short mode.
Option -v prints detailed info:
Show all, global, and a single cluster roles:
Log in to AIS cluster
ais auth login [-p USER_PASS] USER_NAME [--expire EXPIRATION_TIME]
Issue a token for a user.
After successful login, the user’s token is saved to CLI configuration directory (typically ~/.config/ais/cli/) under auth.token filename.
Subsequent ais commands automatically load and use the token for requests to the AIS cluster.
The saved token can be used by other applications, like curl.
Please see AuthN documentation for how to use AuthN API directly.
By default, the AuthN token expiration is 24 hours.
Use option -e or --expire to generate a token with custom expiration time.
Log out
ais auth logout
Delete the user’s token from a local machine. The token is not revoked, so it can be used by any application until it expires. To forbid using the token from any application, the token must be revoked manually in addition to logging out.
Register new cluster
ais auth add cluster [ALIAS] [URL...]
If URL is omitted, CLI registers a cluster using its URL from CLI configuration or AIS_ENDPOINT variable.
When the URL list is defined, CLI tries to connect the cluster using the first URL from the list.
Register the cluster and assign the list of URLs for sending notifications.
A user may assign an alias to the cluster for convenience: AuthN commands accepts both cluster ID and alias in requests.
Alias must be a unique name. Alias is an arbitrary name, but it should not start with http.
In this case, CLI treats the alias as the URL.
On successful cluster registration, AuthN automatically creates a few predefined unique roles for the cluster: with full access, read-write access to all its buckets, and read-only access to the cluster. Please note that the role names include cluster’s alias if it was defined. If the alias is omitted, AuthN adds cluster ID to a role name.
See full example in List registered clusters.
Update existing cluster
ais auth update cluster CLUSTER_ID [ALIAS] URL [URL...]
Replaces the list of URLs or changes alias for an existing cluster.
Unregister existing cluster
ais auth rm cluster CLUSTER_ID
Remove the existing cluster from the notification list.
List registered clusters
ais auth show cluster
Display the list of the cluster that subscribe to AuthN notifications.
Show AuthN server configuration
ais auth show config [--json | PREFIX]
Display the AuthN server configuration in tabular or JSON format. In tabular output, the prefix filters only properties which names start with it.
Change AuthN server configuration
ais auth set config PROP VALUE [PROP VALUE...]
Update AuthN server configuration.
The command allows updating options that can be changed without AuthN server restart.
New property values can be defined either in PROPERTY VALUE or PROPERTY=VALUE form.
Do not forget to update the secret on all clusters if you change AuthN secret. Otherwise, new tokens will be rejected by AIS clusters.