Skip to content

Latest commit

 

History

History
1219 lines (854 loc) · 29.1 KB

authenticate-v3.inc

File metadata and controls

1219 lines (854 loc) · 29.1 KB

Authentication and token management

The Identity service generates tokens in exchange for authentication credentials. A token represents the authenticated identity of a user and, optionally, grants authorization on a specific project, domain, or the deployment system.

The body of an authentication request must include a payload that specifies the authentication methods, which are normally just password or token, the credentials, and, optionally, the authorization scope. You can scope a token to a project, domain, the deployment system, or the token can be unscoped. You cannot scope a token to multiple scope targets.

Tokens have IDs, which the Identity API returns in the X-Subject-Token response header.

In the case of multi-factor authentication (MFA) more than one authentication method needs to be supplied to authenticate. As of v3.12 a failure due to MFA rules only partially being met will result in an auth receipt ID being returned in the response header Openstack-Auth-Receipt, and a response body that details the receipt itself and the missing authentication methods. Supplying the auth receipt ID in the Openstack-Auth-Receipt header in a follow-up authentication request, with the missing authentication methods, will result in a valid token by reusing the successful methods from the first request. This allows MFA authentication to be a multi-step process.

After you obtain an authentication token, you can:

  • Make REST API requests to other OpenStack services. You supply the ID of your authentication token in the X-Auth-Token request header.
  • Validate your authentication token and list the domains, projects, roles, and endpoints that your token gives you access to.
  • Use your token to request another token scoped for a different domain and project.
  • Force the immediate revocation of a token.
  • List revoked public key infrastructure (PKI) tokens.

In v3.7 of the Identity API service, two new configuration options were added: [resource] admin_project_name and [resource] admin_project_domain_name. The options represent the project that only the cloud administrator should be able to access. When an authentication request for a token scoped to the admin project is processed, it will have an additional field in the token {is_admin_project: True}. The additional field can be used when writing policy rules that evaluate access control to APIs.

Alternatively, in v3.10 the Identity API service introduced the concept of system role assignments and system-scoped tokens. APIs that affect the deployment system require system-scoped tokens.

The Identity API considers expired tokens as invalid, which is determined by the deployment's configuration.

These authentication errors can occur:

Authentication errors

Response code Description
Bad Request (400)

The Identity service failed to parse the request as expected. One of the following errors occurred:

  • A required attribute was missing.
  • An attribute that is not allowed was specified, such as an ID on a POST request in a basic CRUD operation.
  • An attribute of an unexpected data type was specified.
Unauthorized (401)

One of the following errors occurred:

  • Authentication was not performed.
  • The specified X-Auth-Token header is not valid.
  • The authentication credentials are not valid.
  • Not all MFA rules were satisfied.
  • The specified Openstack-Auth-Receipt header is not valid.
Forbidden (403) The identity was successfully authenticated but it is not authorized to perform the requested action.
Not Found (404) An operation failed because a referenced entity cannot be found by ID. For a POST request, the referenced entity might be specified in the request body rather than in the resource path.
Conflict (409)

A POST or PATCH operation failed. For example, a client tried to update a unique attribute for an entity, which conflicts with that of another entity in the same collection.

Or, a client issued a create operation twice on a collection with a user-defined, unique attribute. For example, a client made a POST /users request two times for the unique, user-defined name attribute for a user entity.

Password authentication with unscoped authorization

Authenticates an identity and generates a token. Uses the password authentication method. Authorization is unscoped.

The request body must include a payload that specifies the authentication method, which is password, and the user, by ID or name, and password credentials.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Example

./samples/admin/auth-password-unscoped-request-with-domain.json

Response

Parameters

Status Codes

Example

./samples/admin/auth-password-unscoped-response.json

Password authentication with scoped authorization

Authenticates an identity and generates a token. Uses the password authentication method and scopes authorization to a project, domain, or the system.

The request body must include a payload that specifies the password authentication method which includes the credentials in addition to a project, domain, or system authorization scope.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

System-Scoped Example

./samples/auth/requests/system-password.json

Domain-Scoped with Domain ID Example

./samples/auth/requests/domain-id-password.json

Domain-Scoped with Domain Name Example

./samples/auth/requests/domain-name-password.json

Project-Scoped with Project ID Example

./samples/auth/requests/project-id-password.json

Project-Scoped with Project Name Example

./samples/auth/requests/project-name-password.json

Response

Parameters

Status Codes

System-Scoped Example

./samples/auth/responses/system-scoped-password.json

Domain-Scoped Example

./samples/auth/responses/domain-scoped-password.json

Project-Scoped Example

./samples/auth/responses/project-scoped-password.json

Password authentication with explicit unscoped authorization

Authenticates an identity and generates a token. Uses the password authentication method with explicit unscoped authorization.

The request body must include a payload that specifies the password authentication method, the credentials, and the unscoped authorization scope.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Example

./samples/admin/auth-password-explicit-unscoped-request.json

Response

Parameters

Status Codes

Example

./samples/admin/auth-password-explicit-unscoped-response.json

Token authentication with unscoped authorization

Authenticates an identity and generates a token. Uses the token authentication method. Authorization is unscoped.

In the request body, provide the token ID.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Example

./samples/admin/auth-token-unscoped-request.json

Response

Parameters

Status Codes

Example

./samples/admin/auth-token-unscoped-response.json

Token authentication with scoped authorization

Authenticates an identity and generates a token. Uses the token authentication method and scopes authorization to a project, domain, or the system.

The request body must include a payload that specifies the token authentication method which includes the token in addition to a project, domain, or system authorization scope.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

System-Scoped Example

./samples/auth/requests/system-token.json

Domain-Scoped with Domain ID Example

./samples/auth/requests/domain-id-token.json

Domain-Scoped with Domain Name Example

./samples/auth/requests/domain-name-token.json

Project-Scoped with Project ID Example

./samples/auth/requests/project-id-token.json

Project-Scoped with Project Name Example

./samples/auth/requests/project-name-token.json

Response

Parameters

Status Codes

System-Scoped Example

./samples/auth/responses/system-scoped-token.json

Domain-Scoped Example

./samples/auth/responses/domain-scoped-token.json

Project-Scoped Example

./samples/auth/responses/project-scoped-token.json

Token authentication with explicit unscoped authorization

Authenticates an identity and generates a token. Uses the token authentication method with explicit unscoped authorization.

In the request body, provide the token ID and the unscoped authorization scope.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Example

./samples/admin/auth-token-explicit-unscoped-request.json

Response

Parameters

Status Codes

Example

./samples/admin/auth-token-unscoped-response.json

Multi-Step authentication (2-Factor Password and TOTP example)

Authenticates an identity and generates a token. Uses the password authentication method, then the totp method, with an auth receipt in between.

This assumes that MFA has been enabled for the user, and a rule has been defined requiring authentication with both password and totp.

The first request body must at least include a payload that specifies one of password or totp authentication methods which includes the credentials in addition to an optional scope. If only one method is supplied then an auth receipt will be returned. Scope is not retained in the receipt and must be resupplied in subsequent requests.

While it is very possible to supply all the required auth methods at once, this example shows the multi-step process which is likely to be more common.

More than 2 factors can be used but the same process applies to those as well; either all auth methods are supplied at once, or in steps with one or more auth receipts in between.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

First Request

Parameters

Example

./samples/auth/requests/project-id-password.json

Response

Here we are expecting a 401 status, and a returned auth receipt.

Parameters

Status Code

Auth Receipt Example

./samples/auth/responses/auth-receipt-password.json

Second Request

Parameters

Example

./samples/auth/requests/project-id-totp.json

Response

Parameters

Status Codes

Project-Scoped Password and TOTP Example

./samples/auth/responses/project-scoped-password-totp.json

Validate and show information for token

Validates and shows information for a token, including its expiration date and authorization scope.

Pass your own token in the X-Auth-Token request header.

Pass the token that you want to validate in the X-Subject-Token request header.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Response

Parameters

Status Codes

Unscoped Example

./samples/auth/responses/unscoped-password.json

System-Scoped Example

./samples/auth/responses/system-scoped-password.json

Domain-Scoped Example

./samples/auth/responses/domain-scoped-password.json

Project-Scoped Example

./samples/auth/responses/project-scoped-password.json

Check token

Validates a token.

This call is similar to GET /auth/tokens but no response body is provided even in the X-Subject-Token header.

The Identity API returns the same response as when the subject token was issued by POST /auth/tokens even if an error occurs because the token is not valid. An HTTP 204 response code indicates that the X-Subject-Token is valid.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Response

Status Codes

Revoke token

Revokes a token.

This call is similar to the HEAD /auth/tokens call except that the X-Subject-Token token is immediately not valid, regardless of the expires_at attribute value. An additional X-Auth-Token is not required.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

Request

Parameters

Response

Status Codes

Get service catalog

New in version 3.3

This call returns a service catalog for the X-Auth-Token provided in the request, even if the token does not contain a catalog itself (for example, if it was generated using ?nocatalog).

The structure of the catalog object is identical to that contained in a token.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_catalog

Request

Parameters

Response

Parameters

Status Codes

Example

./samples/admin/get-service-catalog-response.json

Get available project scopes

New in version 3.3

This call returns the list of projects that are available to be scoped to based on the X-Auth-Token provided in the request.

The structure of the response is exactly the same as listing projects for a user.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_projects

Request

Parameters

Response

Parameters

Status Codes

Example

./samples/admin/get-available-project-scopes-response.json

Get available domain scopes

New in version 3.3

This call returns the list of domains that are available to be scoped to based on the X-Auth-Token provided in the request.

The structure is the same as listing domains.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_domains

Request

Parameters

Response

Parameters

Status Codes

Example

./samples/admin/get-available-domain-scopes-response.json

Get available system scopes

New in version 3.10

This call returns the list of systems that are available to be scoped to based on the X-Auth-Token provided in the request.

Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_system

Request

Parameters

Response

Parameters

Status Codes

Example

./samples/admin/get-available-system-scopes-response.json