IAM Identity Center credential provider (original) (raw)

This authentication mechanism uses AWS IAM Identity Center to get single sign-on (SSO) access to AWS services for your code.

Note

In the AWS SDK API documentation, the IAM Identity Center credential provider is called the SSO credential provider.

After you enable IAM Identity Center, you define a profile for its settings in your shared AWSconfig file. This profile is used to connect to the IAM Identity Center access portal. When a user successfully authenticates with IAM Identity Center, the portal returns short-term credentials for the IAM role associated with that user. To learn how the SDK gets temporary credentials from the configuration and uses them for AWS service requests, see How IAM Identity Center authentication is resolved for AWS SDKs and tools.

There are two ways to configure IAM Identity Center through the config file:

In both configurations, you need to sign in again when your session expires.

The following two guides contain additional information about IAM Identity Center:

For a deep dive on how the SDKs and tools use and refresh credentials using this configuration, see How IAM Identity Center authentication is resolved for AWS SDKs and tools.

Prerequisites

You must first enable IAM Identity Center. For details about enabling IAM Identity Center authentication, see Enabling AWS IAM Identity Center in the_AWS IAM Identity Center User Guide_.

SSO token provider configuration

When you use the SSO token provider configuration, your AWS SDK or tool automatically refreshes your session up to your extended session period. For more information on session duration and maximum duration, see Configure the session duration of the AWS access portal and IAM Identity Center integrated applications in the_AWS IAM Identity Center User Guide_.

The sso-session section of the config file is used to group configuration variables for acquiring SSO access tokens, which can then be used to acquire AWS credentials. For more details on this section within a config file, see Format of the config file.

The following shared config file example configures the SDK or tool using a dev profile to request IAM Identity Center credentials.

[profile dev]
sso_session = my-sso
sso_account_id = 111122223333
sso_role_name = SampleRole

[sso-session my-sso]
sso_region = us-east-1
sso_start_url = https://my-sso-portal.awsapps.com/start
sso_registration_scopes = sso:account:access

The previous examples shows that you define an sso-session section and associate it to a profile. Typically, sso_account_id andsso_role_name must be set in the profile section so that the SDK can request AWS credentials. sso_region, sso_start_url, andsso_registration_scopes must be set within the sso-session section.

sso_account_id and sso_role_name aren't required for all scenarios of SSO token configuration. If your application only uses AWS services that support bearer authentication, then traditional AWS credentials are not needed. Bearer authentication is an HTTP authentication scheme that uses security tokens called bearer tokens. In this scenario, sso_account_id and sso_role_name aren't required. See the individual AWS service guide to determine if the service supports bearer token authorization.

Registration scopes are configured as part of an sso-session. Scope is a mechanism in OAuth 2.0 to limit an application's access to a user's account. The previous example sets sso_registration_scopes to provide necessary access for listing accounts and roles.

The following example shows how you can reuse the same sso-session configuration across multiple profiles.

[profile dev]
sso_session = my-sso
sso_account_id = 111122223333
sso_role_name = SampleRole

[profile prod]
sso_session = my-sso
sso_account_id = 111122223333
sso_role_name = SampleRole2

[sso-session my-sso]
sso_region = us-east-1
sso_start_url = https://my-sso-portal.awsapps.com/start
sso_registration_scopes = sso:account:access

The authentication token is cached to disk under the ~/.aws/sso/cache directory with a file name based on the session name.

Legacy non-refreshable configuration

Automated token refresh isn't supported using the legacy non-refreshable configuration. We recommend using the SSO token provider configuration instead.

To use the legacy non-refreshable configuration, you must specify the following settings within your profile:

You specify the user portal for a profile with the sso_start_url andsso_region settings. You specify permissions with thesso_account_id and sso_role_name settings.

The following example sets the four required values in the config file.

[profile my-sso-profile]
sso_start_url = https://my-sso-portal.awsapps.com/start
sso_region = us-west-2
sso_account_id = 111122223333
sso_role_name = SSOReadOnlyRole

The authentication token is cached to disk under the ~/.aws/sso/cache directory with a file name based on the sso_start_url.

IAM Identity Center credential provider settings

Configure this functionality by using the following:

sso_start_url - shared AWS config file setting

The URL that points to your organization's IAM Identity Center issuer URL or access portal URL. For more information, see Using the AWS access portal in the AWS IAM Identity Center User Guide.

To find this value, open the IAM Identity Center console, view the Dashboard, find AWS access portal URL.

sso_region - shared AWS config file setting

The AWS Region that contains your IAM Identity Center portal host; that is, the Region you selected before enabling IAM Identity Center. This is independent from your default AWS Region, and can be different.

For a complete list of the AWS Regions and their codes, see Regional Endpoints in the Amazon Web Services General Reference. To find this value, open the IAM Identity Center console, view theDashboard, and find Region.

sso_account_id - shared AWS config file setting

The numeric ID of the AWS account that was added through the AWS Organizations service to use for authentication.

To see the list of available accounts, go to the IAM Identity Center console and open theAWS accounts page. You can also see the list of available accounts using the ListAccounts API method in the AWS IAM Identity Center Portal API Reference. For example, you can call the AWS CLI method list-accounts.

sso_role_name - shared AWS config file setting

The name of a permission set provisioned as an IAM role that defines the user's resulting permissions. The role must exist in the AWS account specified bysso_account_id. Use the role name, not the role Amazon Resource Name (ARN).

Permission sets have IAM policies and custom permissions policies attached to them and define the level of access that users have to their assigned AWS accounts.

To see the list of available permission sets per AWS account, go to the IAM Identity Center console and open theAWS accounts page. Choose the correct permission set name listed in the AWS accounts table. You can also see the list of available permission sets using the ListAccountRoles API method in the AWS IAM Identity Center Portal API Reference. For example, you can call the AWS CLI method list-account-roles.

sso_registration_scopes - shared AWS config file setting

A comma-delimited list of valid scope strings to be authorized for thesso-session. An application can request one or more scopes, and the access token issued to the application is limited to the scopes granted. A minimum scope of sso:account:access must be granted to get a refresh token back from the IAM Identity Center service. For the list of available access scope options, see Access scopes in the AWS IAM Identity Center User Guide.

These scopes define the permissions requested to be authorized for the registered OIDC client and access tokens retrieved by the client. Scopes authorize access to IAM Identity Center bearer token authorized endpoints.

This setting doesn't apply to the legacy non-refreshable configuration. Tokens issued using the legacy configuration are limited to scopesso:account:access implicitly.

Support by AWS SDKs and tools

The following SDKs support the features and settings described in this topic. Any partial exceptions are noted. Any JVM system property settings are supported by the AWS SDK for Java and the AWS SDK for Kotlin only.