User Management
This document describes how to create and manage users and configure user access privileges.
API concepts
The NuoDB Control Plane REST API exposes access to resources in a hierarchical structure.
- An organization contains several projects and users.
- A user is an entity that authenticates itself and issues requests to resources that it has been granted access to.
- A project contains several databases and enables both logical and physical separation between databases. Databases belonging to the same project share resources associated with the project (i.e. a NuoDB domain), while databases in different projects do not share these resources and are more isolated from each other.
The /users
resource
The /users
resource of the Control Plane REST API has the following request methods.
GET /users/<organization>
lists all of the users within an organization.GET /users/<organization>/<user>
returns a specific user.PUT /users/<organization>/<user>
creates a new user, or updates an existing one if theresourceVersion
field is specified in the request payload.PATCH /users/<organization>/<user>
updates an existing user by applying the JSONPatch operations specified.DELETE /users/<organization>/<user>
deletes an existing user.
Note
Similar conventions are also followed for the /projects
and /databases
resources.
The specification of a user has the following format:
As with the /projects/<organization>/<project>
and /databases/<organization>/<project>/<database>
resources, the resourceVersion
is an opaque value generated by the system and appearing in GET
response payloads.
When the user specifies it in a PUT
request payload, an update of the existing resource is performed.
Note
An update will fail with status code 409 Conflict
if a concurrent update caused the resourceVersion
to change.
The password
field does not appear in the response payload for GET /users/<organization>/<user>
and is only required when creating a new user or updating the password of an existing user.
The password is not retained by the system.
It is used to compute a verifier that is stored persistently and used to verify authentication credentials on future requests by the user.
The fields organization
and name
are redundant with the path parameters in the users/<organization>/<user>
resource, so they can be omitted from PUT
request payloads.
Specifying access rules
The value of the accessRule
field has the following format:
The allow
and deny
fields accept arrays of access rule entries that grant and deny access, respectively.
An access rule entry has the format <verb>:<resource specifier>[:<SLA>]
.
Verb
A verb is one of the following and is associated with one or more HTTP methods.
verb | HTTP methods |
---|---|
read | GET |
write | PUT , PATCH |
delete | DELETE |
all | GET , PUT , PATCH , DELETE |
Resource specifier
A resource specifier takes one of two forms:
- If a resource specifier starts with
/
, then it is interpreted as an absolute resource path. The first component of the path must be one of/projects
,/databases/
,/users
, and/healthz
. - Otherwise, it is interpreted as a scope, which has the format
<organization>/<project>/<database>
,<organization>/<project>
, or<organization>
. A scope binds to a specific object in the hierarchy of DBaaS objects (organizations, projects, databases) and expands to the set of resource paths associated with that object. For example, the scopeacme
expands to the resource paths/projects/acme/*
,/databases/acme/*
, and/users/acme/*
, whileacme/messaging
expands to/projects/acme/messaging/*
and/databases/acme/messaging/*
.
SLA
An optional third component of the access rule entry limits access to only projects that have matching SLA values and databases within projects that have matching SLA values.
For example, write:acme:dev
would grant write access to all projects within the acme
organization with SLA dev
and all of their databases.
Only allow
entries accept an SLA value.
Example: Full access
To grant full access to all resources, the wildcard resource can be specified.
Note
Either (or both) of the allow
and deny
fields in the access rule can be omitted or supplied with a string value, which expands to a single element array.
Example: Read and write access at different levels
To grant read access at the organization level and write access at the project level, the following can be specified.
The rule above allows projects, databases, and users to be listed for the organization acme
and allows the specific project acme/messaging
to be written, as well as any database within acme/messaging
.
Example: Access to specific resource paths
Access can be granted to specific resource paths as follows:
In the example above, the resource /users/acme/dbuser
is specified to grant full access to that specific user.
This would allow a user to change its own password without having access to all resources at the organization level.
Example: Denying access to resource paths
Access to specific resource paths can also be explicitly denied using the deny
field.
In the example above, full access is granted for all resources in the acme
organization, except users.
Note that this is equivalent to the following access rule, assuming that the set of root resources expanded by an organization scope is /projects
, /databases
, and /users
:
Although the two access rules are equivalent for the current version of the Control Plane REST API, they would behave differently if changes are made to the API. The former would grant access to any organization-scoped resources that are added to the API, while the latter would not. It is up to the administrator to decide which approach is best.
Example: Access to multiple organizations
Even though each user belongs to a specific organization, it is possible to grant users access to multiple organizations, as shown below:
Note
Adding access outside of a user’s organization requires specifying the query parameter allowCrossOrganizationAccess=true
, which is accepted by both PUT
and PATCH
requests on the user resource.
Example: Access constrained by SLA
To grant access to only the projects and databases within a scope that have a particular SLA value, an SLA constraint can be specified:
In the example above, full access is granted to all projects and databases in acme
that have SLA dev
, read access is granted to projects and databases in acme
that have SLA qa
, and write access is granted to the specific project acme/messaging
.
Authentication
The authentication method supported by the Control Plane REST API is HTTP basic authentication.
The user name is supplied in the format <organization>/<user>
along with the password.
To authenticate using curl
:
To authenticate using the httpclient
subcommand of the nuodb-cp
tool:
If the REST server property com.nuodb.controlplane.server.bypassLocalAuthentication
is set to true
, then authentication and access control can be bypassed by issuing requests from a client on the same host as the REST server.
Creating users
Assuming that we are logged into the same host as a REST server configured with com.nuodb.controlplane.server.bypassLocalAuthentication=true
, a user with organization level access can be created as follows:
Users can be created with more restrictive access rules as follows:
The example above creates two users as the newly-created organization admin, one to manage a project and another to manage a database.
Verifying access
The expected access privileges can be verified by issuing requests as the created users. The commands below create a project as the project admin and a database as the database admin, which verifies write access.
To verify read access, issue various read requests:
To verify expected access limits, issue various requests outside of granted scopes, which should fail with status code 403 Forbidden
:
Updating users
Users can be updated to change their access privileges or change their password.
To demonstrate updating of access privileges, first read the user resource:
Next, use the PATCH
method to add an entry to the allow
array of the access rule:
Note
The suffix -
for the path
indicates that the value should be appended to the specified array.
To verify that the change was made, read the user resource again, this time as the affected user (projadmin
), which was previously unable to access its own user resource:
The PATCH
method can also be used to update a user’s password as follows:
Deleting users
Finally, a user can be deleted as follows:
Note
The request above actually deletes the user resource for the user issuing the request, which is legal.