Get started with OAuth Applications
You can access the OAuth Applications page from the navigation panel by selecting . From there you can view, create, sort and search for applications currently managed by Ansible Automation Platform and automation controller.
If no applications exist, you can create one by clicking .
Application functions
Several OAuth 2 utilities are available for authorization, token refresh, and revoke. You can specify the following grant types when creating an application:
- Password
- This grant type is ideal for users who have native access to the web application and must be used when the client is the resource owner.
- Authorization code
- This grant type should be used when access tokens must be issued directly to an external application or service.
You can only use the authorization code type to acquire an access token when using an application. When integrating an external web application with Ansible Automation Platform, that web application might need to create OAuth2 tokens on behalf of users in that other web application. Creating an application in the platform with the authorization code grant type is the preferred way to do this because:
- This allows an external application to obtain a token from Ansible Automation Platform for a user, using their credentials.
- Compartmentalized tokens issued for a particular application enables those tokens to be easily managed. For example, revoking all tokens associated with that application without having to revoke all tokens in the system.
Refresh an access token after expiration
You can use a refresh token to request a new access token after the original token expires.
About this task
The default expiration for OAuth2 access tokens is 31,536,000 seconds (1 year). You can configure this value in the OAUTH2_PROVIDER settings in etc/ansible-automation-platform/gateway/settings.py.
When an access token expires, use the original refresh token to request a new access token without re-authorizing.
Procedure
What to do next
REFRESH_TOKEN_EXPIRE_SECONDS setting in OAUTH2_PROVIDER in /etc/ansible-automation-platform/gateway/settings.py.
OAuth2 application and token migration (2.4 to 2.6)
During the upgrade from Ansible Automation Platform 2.4 to 2.6, there are important changes to how OAuth2 applications and tokens are managed. Ansible Automation Platform now uses platform gateway OAuth applications and deprecates automation controller OAuth applications.
- Automation controller OAuth applications: You can view and edit existing automation controller applications, but new ones can no longer be created. These legacy applications continue to function, but they might be removed in a future release. Plan to migrate to platform gateway OAuth applications.
- Automation controller tokens: Automation controller personal access tokens (PATs), are also deprecated. Guide users to move to platform gateway PATs.
- Platform gateway OAuth applications and tokens: Platform applications and tokens offer an updated interface and are the standard for future use. Move to these applications and tokens.
Manage OAUTH2_PROVIDER settings
The OAUTH2_PROVIDER settings from automation controller are managed by platform gateway after upgrading from 2.4. to 2.6. The default token expiration values might differ between automation controller and platform gateway.
- The default access token expiration is updated from 1,000 years to 1 year. This change increases credential security through more frequent token rotation.
- Platform gateway’s default OAUTH2_PROVIDER settings are:
{ "ACCESS_TOKEN_EXPIRE_SECONDS": 31536000, "REFRESH_TOKEN_EXPIRE_SECONDS": 2628000, "AUTHORIZATION_CODE_EXPIRE_SECONDS": 600 }If you previously set a token expiration shorter than one year, you must manually update the platform gateway settings to match your required configuration.
Configure the OAuth access token lifetime on OpenShift Container Platform
On an operator-based installation, set the OAuth access token lifetime in the AnsibleAutomationPlatform custom resource so platform gateway applies it across reconciliations.
Before you begin
- Cluster access to edit the
AnsibleAutomationPlatformcustom resource (CR).
About this task
Set the OAuth access token lifetime in the AnsibleAutomationPlatform CR by using spec.extra_settings.
Do not edit the operator-managed platform gateway settings Secret directly. The operator regenerates that Secret from the CR, so manual edits are lost on the next reconciliation.
Procedure
What to do next
- Changing the lifetime affects only newly created tokens. Existing tokens keep their original expiration.
- Avoid extremely short lifetimes. A short lifetime can affect the operator service-account OAuth token if that token is recreated after the setting is applied.