Este conteúdo não está disponível no idioma selecionado.
Chapter 8. Application Credentials
Application Credentials help you 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 only gains access to the one project and role that it needs to function, rather than all of them.
This approach allows you to consume an API with revealing your user credentials, and lets applications 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.
8.1. Use Application Credentials to generate tokens Copiar o linkLink copiado para a área de transferência!
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
. For example:openstack project create AppCreds
$ openstack project create AppCreds
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a user called
AppCredsUser
. For example: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 the_member_
role for theAppCreds
project. For example: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
Login to the dashboard as
AppCredsUser
and create an Application Credential:Overview
Identity
Application Credentials
+Create Application Credential
.NoteBe sure to download the
clouds.yaml
file contents, as you will not be able to access it again once 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. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThese exact 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
.
8.2. Integrate Application Credentials with applications Copiar o linkLink copiado para a área de transferência!
Application Credentials can be used to authenticate applications to keystone. When using Application Credentials, the keystone_authtoken
settings use v3applicationcredential
as the authentication type and will contain the credentials you received during the credential creation process. You will need to enter the following values:
-
application_credential_secret
: The Application Credential secret. -
application_credential_id
: The Application Credential id. -
application_credential_name
: (Optional) - You might use this if using 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>"
8.3. Use the command line to manage Application Credentials Copiar o linkLink copiado para a área de transferência!
You can use the command line to create and delete Application Credentials.
The create
subcommand will create 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:
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 only delegating access to a specific role. For example:
To delete an Application Credential:
openstack application credential delete AppCredsUser
$ openstack application credential delete AppCredsUser
8.4. Operational tasks Copiar o linkLink copiado para a área de transferência!
8.4.1. Replace an existing Application Credential Copiar o linkLink copiado para a área de transferência!
Application Credentials are bound to the user account that created them and will 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.
8.4.1.1. For configuration files Copiar o linkLink copiado para a área de transferência!
To 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’s configuration file, replacing the existing credentials. This is described in Section 8.2, “Integrate Application Credentials with applications”.
- Restart the application’s service to apply the change.
- Delete the old Application Credential, if appropriate. For more information on the command line options, see Section 8.3, “Use the command line to manage Application Credentials”.
8.4.1.2. For clouds.yaml files Copiar o linkLink copiado para a área de transferência!
To replace an existing Application Credential used by clouds.yaml
:
For example, if your clouds.yaml
contains an Application Credential called AppCred1
, and it is due to expire:
- Create an Application Credential called AppCred2.
-
Add the new
AppCred2
to theclouds.yaml
file, while removing theAppCred1
configuration. -
Generate a token with
clouds.yaml
to confirm that the credentials are working as expected. See step 4 of Section 8.1, “Use Application Credentials to generate tokens” for more information.