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
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
Create a user called
AppCredsUser
:$ openstack user create --project AppCreds --password-prompt AppCredsUser
Grant
AppCredsUser
access to themember
role for theAppCreds
project:$ openstack role add --user AppCredsUser --project AppCreds member
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.# This is a clouds.yaml file, which can be used by OpenStack tools as a source # of configuration on how to connect to a cloud. If this is your only cloud, # just put this file in ~/.config/openstack/clouds.yaml and tools like # python-openstackclient will just work with no further config. (You will need # to add your password to the auth section) # If you have more than one cloud account, add the cloud entry to the clouds # section of your existing file and you can refer to them by name with # OS_CLOUD=openstack or --os-cloud=openstack clouds: openstack: auth: auth_url: http://10.0.0.10:5000/v3 application_credential_id: "6d141f23732b498e99db8186136c611b" application_credential_secret: "<example secret value>" region_name: "regionOne" interface: "public" identity_api_version: 3 auth_type: "v3applicationcredential"
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.[stack@undercloud-0 openstack]$ openstack --os-cloud=openstack token issue +------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Field | Value | +------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | expires | 2018-08-29T05:37:29+0000 | | id | gAAAAABbhiMJ4TxxFlTMdsYJpfStsGotPrns0lnpvJq9ILtdi-NKqisWBeNiJlUXwmnoGQDh2CMyK9OeTsuEXnJNmFfKjxiHWmcQVYzAhMKo6_QMUtu_Qm6mtpzYYHBrUGboa_Ay0LBuFDtsjtgtvJ-r8G3TsJMowbKF-yo--O_XLhERU_QQVl3hl8zmMRdmLh_P9Cbhuolt | | project_id | 1a74eabbf05c41baadd716179bb9e1da | | user_id | ef679eeddfd14f8b86becfd7e1dc84f2 | +------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
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. Integrate Application Credentials with applications
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>"
9.3. Use the command line to manage Application Credentials
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:
$ openstack application credential create --description "App Creds - All roles" AppCredsUser +--------------+----------------------------------------------------------------------------------------+ | Field | Value | +--------------+----------------------------------------------------------------------------------------+ | description | App Creds - All roles | | expires_at | None | | id | fc17651c2c114fd6813f86fdbb430053 | | name | AppCredsUser | | project_id | 507663d0cfe244f8bc0694e6ed54d886 | | roles | member reader admin | | secret | fVnqa6I_XeRDDkmQnB5lx361W1jHtOtw3ci_mf_tOID-09MrPAzkU7mv-by8ykEhEa1QLPFJLNV4cS2Roo9lOg | | unrestricted | False | +--------------+----------------------------------------------------------------------------------------+
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:
$ openstack application credential create --description "App Creds - Member" --role member AppCredsUser +--------------+----------------------------------------------------------------------------------------+ | Field | Value | +--------------+----------------------------------------------------------------------------------------+ | description | App Creds - Member | | expires_at | None | | id | e21e7f4b578240f79814085a169c9a44 | | name | AppCredsUser | | project_id | 507663d0cfe244f8bc0694e6ed54d886 | | roles | member | | secret | XCLVUTYIreFhpMqLVB5XXovs_z9JdoZWpdwrkaG1qi5GQcmBMUFG7cN2htzMlFe5T5mdPsnf5JMNbu0Ih-4aCg | | unrestricted | False | +--------------+----------------------------------------------------------------------------------------+
To delete an Application Credential:
$ openstack application credential delete AppCredsUser
9.4. Operational tasks
9.4.1. Replace an existing Application Credential
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.
9.4.2. 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 Section 9.2, “Integrate 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 Section 9.3, “Use the command line to manage Application Credentials”.
9.4.3. For clouds.yaml files
Replace an existing Application Credential used by clouds.yaml
:
For example, if your clouds.yaml
contains an Application Credential called AppCred1
that 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 9.1, “Using Application Credentials to generate tokens” for more information.