Este contenido no está disponible en el idioma seleccionado.
Chapter 9. Application credentials
Use Application Credentials to avoid the practice of embedding user account credentials in configuration files. Instead, the user creates an Application Credential that receives delegated access to a single project and has its own distinct secret. The user can also limit the delegated privileges to a single role in that project. This allows you to adopt the principle of least privilege, where the authenticated service gains access only to the one project and role that it needs to function, rather than all projects and roles.
You can use this methodology to consume an API without revealing your user credentials, and applications can authenticate to Keystone without requiring embedded user credentials.
You can use Application Credentials to generate tokens and configure keystone_authtoken
settings for applications. These use cases are described in the following sections.
The Application Credential is dependent on the user account that created it, so it will terminate if that account is ever deleted, or loses access to the relevant role.
9.1. Using Application Credentials to generate tokens Copiar enlaceEnlace copiado en el portapapeles!
Application Credentials are available to users as a self-service function in the dashboard. This example demonstrates how a user can create an Application Credential and then use it to generate a token.
Create a test project, and test user accounts:
Create a project called
AppCreds
:openstack project create AppCreds
$ openstack project create AppCreds
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a user called
AppCredsUser
:openstack user create --project AppCreds --password-prompt AppCredsUser
$ openstack user create --project AppCreds --password-prompt AppCredsUser
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Grant
AppCredsUser
access to themember
role for theAppCreds
project:openstack role add --user AppCredsUser --project AppCreds member
$ openstack role add --user AppCredsUser --project AppCreds member
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Log in to the dashboard as
AppCredsUser
and create an Application Credential:Overview
Identity
Application Credentials
+Create Application Credential
.NoteEnsure that you download the
clouds.yaml
file contents, because you cannot access it again after you close the pop-up window titledYour Application Credential
.Create a file named
/home/stack/.config/openstack/clouds.yaml
using the CLI and paste the contents of theclouds.yaml
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThese values will be different for your deployment.
Use the Application Credential to generate a token. You must not be sourced as any specific user when using the following command, and you must be in the same directory as your
clouds.yaml
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If you receive an error similar to init() got an unexpected keyword argument 'application_credential_secret'
, then you might still be sourced to the previous credentials. For a fresh environment, run sudo su - stack
.
9.2. Integrating Application Credentials with applications Copiar enlaceEnlace copiado en el portapapeles!
Application Credentials can be used to authenticate applications to keystone. When you use Application Credentials, the keystone_authtoken
settings use v3applicationcredential
as the authentication type and contain the credentials that you receive during the credential creation process. Enter the following values:
-
application_credential_secret
: The Application Credential secret. -
application_credential_id
: The Application Credential id. -
(Optional)
application_credential_name
: You might use this parameter if you use a named application credential, rather than an ID.
For example:
[keystone_authtoken] auth_url = http://10.0.0.10:5000/v3 auth_type = v3applicationcredential application_credential_id = "6cb5fa6a13184e6fab65ba2108adf50c" application_credential_secret = "<example password>"
[keystone_authtoken]
auth_url = http://10.0.0.10:5000/v3
auth_type = v3applicationcredential
application_credential_id = "6cb5fa6a13184e6fab65ba2108adf50c"
application_credential_secret = "<example password>"
9.3. Managing Application Credentials Copiar enlaceEnlace copiado en el portapapeles!
You can use the command line to create and delete Application Credentials.
The create
subcommand creates an application credential based on the currently sourced account. For example, creating the credential when sourced as an admin
user will grant the same roles to the Application Credential:
Using the --unrestricted
parameter enables the application credential to create and delete other application credentials and trusts. This is potentially dangerous behavior and is disabled by default. You cannot use the --unrestricted
parameter in combination with other access rules.
By default, the resulting role membership includes all the roles assigned to the account that created the credentials. You can limit the role membership by delegating access only to a specific role:
To delete an Application Credential:
openstack application credential delete AppCredsUser
$ openstack application credential delete AppCredsUser
9.4. Replacing Application Credentials Copiar enlaceEnlace copiado en el portapapeles!
Application credentials are bound to the user account that created them and become invalid if the user account is ever deleted, or if the user loses access to the delegated role. As a result, you should be prepared to generate a new application credential as needed.
Replacing existing application credentials for configuration files
Update the application credentials assigned to an application (using a configuration file):
- Create a new set of application credentials.
- Add the new credentials to the application configuration file, replacing the existing credentials. For more information, see Integrating Application Credentials with applications.
- Restart the application service to apply the change.
- Delete the old application credential, if appropriate. For more information about the command line options, see Managing Application Credentials.
Replacing the existing application credentials in clouds.yaml
When you replace an application credential used by clouds.yaml
, you must create the replacement credentials using OpenStack user credentials. By default, you cannot use application credentials to create another set of application credentials. The openstack application credential create
command creates an application credential based on the currently sourced account.
-
Authenticate as the OpenStack user that originally created the authentication credentials that are about to expire. For example, if you used the procedure Using Application Credentials to generate tokens, you must log in again as
AppCredsUser
. Create an Application Credential called
AppCred2
. This can be done using the OpenStack Dashboard, or theopenstack
CLI interface:openstack application credential create --description "App Creds 2 - Member" --role member AppCred2
openstack application credential create --description "App Creds 2 - Member" --role member AppCred2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Copy the
id
andsecret
parameters from the output of the previous command. Thesecret
parameter value cannot be accessed again. -
Replace the
application_credential_id
andapplication_credential_secret
parameter values in the${HOME}/.config/openstack/clouds.yaml
file with thesecret
andid
values that you copied.
Verification
Generate a token with clouds.yaml to confirm that the credentials are working as expected. You must not be sourced as any specific user when using the following command, and you must be in the same directory as your
clouds.yaml
file:openstack --os-cloud=openstack token issue
[stack@undercloud-0 openstack]$ openstack --os-cloud=openstack token issue
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow