S3 Access Grants and corporate directory identities
You can use Amazon S3 Access Grants to grant access to AWS Identity and Access Management (IAM) principals (users or roles), both in the same AWS account and in others. However, in many cases, the entity accessing the data is an end user from your corporate directory. Instead of granting access to IAM principals, you can use S3 Access Grants to grant access directly to your corporate users and groups. With S3 Access Grants, you no longer need to map your corporate identities to intermediate IAM principals in order to access your S3 data through your corporate applications.
You can bring your corporate identities to S3 Access Grants in two ways.
-
IAM federation. Your users sign in to your external identity provider (IdP) and federate into AWS through a shared IAM role. S3 Access Grants matches your grants against the user identity in the IAM session. This path doesn't require an IAM Identity Center instance associated with your S3 Access Grants instance. For more information, see Use IAM federation.
-
AWS IAM Identity Center. Your users sign in through IAM Identity Center, and you create grants for the users and groups in it. New IAM Identity Center instances use the simplified experience for trusted identity propagation. They work with S3 Access Grants without any extra setup. With the simplified experience, IAM Identity Center adds the user's identity to each AWS session. If you have an existing IAM Identity Center instance that isn't opted in yet, associate it with your S3 Access Grants instance until you opt in. For more information, see Use AWS IAM Identity Center.
Both paths use trusted identity propagation. Trusted identity propagation adds the
identity of the signed-in user to the AWS session that an application uses, so that
AWS services can authorize and log requests for that user. You use the same
DIRECTORY_USER and DIRECTORY_GROUP grantee types for both paths.
For how to create these grants, see Create grants.
Use IAM federation
With trusted identity propagation for IAM federation, users from your external IdP,
such as Okta or Microsoft Entra ID, federate into
AWS with AssumeRoleWithWebIdentity or AssumeRoleWithSAML.
Many users can share one IAM role. IAM adds the user's identity from the IdP token
to each session. When your application calls GetDataAccess with that
session, S3 Access Grants matches grants for the individual user, not only for the shared
role.
This path doesn't use the token exchange (CreateTokenWithIAM) that the
IAM Identity Center path uses. You don't need to associate an IAM Identity Center instance with your S3 Access Grants
instance. You set up the IdP and the identity mapping in IAM. For more information,
see OIDC federation
and SAML 2.0
federation in the IAM User
Guide.
Grants for federated users
You can create the following grants for federated users. The grantee identifier must match the value in the user's session exactly.
-
Directory user. Grantee type
DIRECTORY_USER. The identifier is the subject that IAM sets for the user from the IdP token, for example, the user ID00u1a2b3c4EXAMPLEfrom your IdP. In IAM policies, this value is theaws:OriginIdentity/Subjectcondition key. -
Directory group. Grantee type
DIRECTORY_GROUP. The identifier is the group name, for example,finance-analysts. Group grants match only when your IAM identity provider is linked to an IAM Identity Center directory that contains the user and the group. -
Attribute. Grantee type
ATTRIBUTE. The identifier is one claim from the IdP token and its value, in the formaws:TransactionContext/IdentityProvider/, for example,key=valueaws:TransactionContext/IdentityProvider/department=Finance.
The identifiers and attributes that you configure are included in each user's temporary credentials. AWS uses them to authorize requests and records them in AWS CloudTrail and service logs. Don't include sensitive, confidential, or personal information, such as email addresses. As a best practice, use an opaque value that doesn't change, such as the immutable user ID from your IdP. If you use an email address and a user's email address changes, grants for the old address no longer match that user.
S3 Access Grants compares identifiers exactly, and the comparison is case sensitive. For
example, a grant for 00u1a2b3c4EXAMPLE doesn't match a session with
the subject 00U1A2B3C4EXAMPLE. If you change which IdP claim IAM
maps to the subject, existing grants for the old values no longer match. For other
reasons a saved grant might not match, see Why a saved grant might not give access.
Grants for directory users, directory groups, and attributes match the value
in the session, not the identity provider that sent it. If your account has
more than one IAM identity provider, each one can send the same user name.
Anyone who can create an IAM identity provider
(iam:CreateSAMLProvider or
iam:CreateOpenIDConnectProvider) and update a role's trust
policy can create sessions that match your grants. Treat these permissions as
data access permissions, and give them only to trusted administrators. To allow
only identity providers that you trust, use the
aws:OriginIdentity/Issuer condition key in a resource control
policy (RCP). If you share your S3 Access Grants instance with another account, you can
also add the condition key to the Allow statement in your
instance resource policy. For an example, see Limit where users of your shared instance can sign in from.
How a federated user gets access to S3 data
Suppose that a user signs in to your data application through Okta. The application receives an ID token that contains the following claims.
{ "iss": "https://idp.example.com", "sub": "00u1a2b3c4EXAMPLE", "aud": "0oa1b2c3d4EXAMPLE", "department": "Finance" }
The application calls AssumeRoleWithWebIdentity with the token. To
use the following example command, replace
with your account ID,
111122223333 with the name of your
role, data-app-role with a session name,
and data-app-session with the file that contains
the ID token.id-token.jwt
aws sts assume-role-with-web-identity \ --role-arn "arn:aws:iam::111122223333:role/data-app-role" \ --role-session-namedata-app-session\ --web-identity-tokenfile://id-token.jwt
IAM adds the user's identity to the session. In this example, the session contains the following values.
-
aws:OriginIdentity/Issuerisidp.example.com. -
aws:OriginIdentity/Subjectis00u1a2b3c4EXAMPLE. -
aws:TransactionContext/IdentityProvider/departmentisFinance.
The application then calls GetDataAccess with the session
credentials. This is the same call that any grantee makes. The IAM role needs
permission for s3:GetDataAccess.
aws s3control get-data-access \ --account-id111122223333\ --target s3://amzn-s3-demo-bucket/finance/* \ --permission READ
S3 Access Grants returns temporary credentials if a grant matches the role, the user
00u1a2b3c4EXAMPLE, or the attribute department=Finance. The
application uses these credentials to read the S3 data.
Use AWS IAM Identity Center
IAM Identity Center supports standards-based identity providers and is the hub in AWS for any services or features, including S3 Access Grants, that support end-user identities. IAM Identity Center provides authentication support for corporate identities through its trusted identity propagation feature. For more information, see Trusted identity propagation across applications.
To get started with workforce identity support in S3 Access Grants through IAM Identity Center, as a prerequisite, you start in IAM Identity Center by configuring identity provisioning between your corporate identity provider and IAM Identity Center. IAM Identity Center supports corporate identity providers such as Okta, Microsoft Entra ID (formerly Azure Active Directory), or any other external identity provider (IdP) that supports the System for Cross-domain Identity Management (SCIM) protocol. When you connect IAM Identity Center to your IdP and enable automatic provisioning, the users and groups from your IdP are synchronized into the identity store in IAM Identity Center. After this step, IAM Identity Center has its own view of your users and groups, so that you can refer to them by using other AWS services and features, such as S3 Access Grants. For more information about configuring IAM Identity Center automatic provisioning, see Automatic provisioning in the AWS IAM Identity Center User Guide.
IAM Identity Center is integrated with AWS Organizations so that you can centrally manage permissions across multiple AWS accounts without configuring each of your accounts manually. In a typical organization, your identity administrator configures one IAM Identity Center instance for the entire organization, as a single point of identity synchronization. This IAM Identity Center instance typically runs in a dedicated AWS account in your organization. In this common configuration, you can refer to user and group identities in S3 Access Grants from any AWS account in the organization.
However, if your AWS Organizations administrator hasn't yet configured a central IAM Identity Center instance, you can create a local one in the same account and AWS Region as your S3 Access Grants instance. If you have an IAM Identity Center instance configured in a different AWS Region, you can also replicate this instance to the same AWS Region as your S3 Access Grants instance. Such a configuration is more common for proof-of-concept or local development use cases. In all cases, the IAM Identity Center instance must be in the same AWS Region as the S3 Access Grants instance to which it will be associated.
In the following diagram of an IAM Identity Center configuration with an external IdP, the IdP is configured with SCIM to synchronize the identity store from the IdP to the identity store in IAM Identity Center.
To use your corporate directory identities with S3 Access Grants, do the following:
-
Set up Automatic provisioning in IAM Identity Center to synchronize user and group information from your IdP into IAM Identity Center.
-
Configure your external identity source within IAM Identity Center as a trusted token issuer. For more information, see Trusted identity propagation across applications in the AWS IAM Identity Center User Guide.
-
If your IAM Identity Center instance is opted in to the simplified experience for trusted identity propagation, you don't need to associate it with your S3 Access Grants instance. New IAM Identity Center instances are opted in. If you have an existing IAM Identity Center instance that isn't opted in yet, associate it with your S3 Access Grants instance until you opt in. For more information, see Associate or disassociate your IAM Identity Center instance.
How directory identities can access S3 data
Suppose that you have corporate directory users who need to access your S3 data
through a corporate application, for example, a document-viewer application, that is
integrated with your external IdP (for example, Okta) to authenticate
users. Authentication of the user in these applications is typically done through
redirects in the user's web browser. Because users in the directory are not IAM
principals, your application needs IAM credentials with which it can call the S3 Access Grants
GetDataAccess API operation to get access
credentials to S3 data on the users' behalf. Unlike IAM users and roles
who get credentials themselves, your application needs a way to represent a directory
user, who isn't mapped to an IAM role, so that the user can get data access through
S3 Access Grants.
This transition, from authenticated directory user to an IAM caller that can make requests to S3 Access Grants on behalf of the directory user, is done by the application through the trusted token issuer feature of IAM Identity Center. The application, after authenticating the directory user, has an identity token from the IdP (for example, Okta) that represents the directory user according to Okta. The trusted token issuer configuration in IAM Identity Center enables the application to exchange this Okta token (the Okta tenant is configured as the "trusted issuer") for a different identity token from IAM Identity Center that will securely represent the directory user within AWS services. The data application will then assume an IAM role, providing the directory user's token from IAM Identity Center as additional context. The application can use the resulting IAM session to call S3 Access Grants. The token represents both the identity of the application (the IAM principal itself) as well as the directory user's identity.
The main step of this transition is the token exchange. The application performs this
token exchange by calling the CreateTokenWithIAM API operation in IAM Identity Center. Of
course, that too is an AWS API call and requires an IAM principal to sign it. The
IAM principal that makes this request is typically an IAM role that's associated
with the application. For example, if the application runs on Amazon EC2, the
CreateTokenWithIAM request is typically performed by the IAM role
that's associated with the EC2 instance on which the application runs. The result of a
successful CreateTokenWithIAM call is a new identity token, which will be
recognized within AWS services.
The next step, before the application can call GetDataAccess on the
directory user's behalf, is for the application to obtain an IAM session that includes
the directory user's identity. The application does this with an AWS Security Token Service (AWS STS)
AssumeRole request that also includes the IAM Identity Center token for the directory
user as additional identity context. This additional context is what enables IAM Identity Center to
propagate the directory user's identity to the next step. The IAM role that the
application assumes is the role that will need IAM permissions to call the
GetDataAccess operation.
Having assumed the identity bearer IAM role with the IAM Identity Center token for the directory
user as additional context, the application now has everything it needs to make a signed
request to GetDataAccess on behalf of the authenticated directory
user.
Token propagation is based on the following steps:
Create an IAM Identity Center application
First, create a new application in IAM Identity Center. This application will use a template that allows IAM Identity Center to identify which type of application settings that you can use. The command to create the application requires you to provide the IAM Identity Center instance Amazon Resource Name (ARN), an application name, and the application provider ARN. The application provider is the SAML or OAuth application provider that the application will use to make calls to IAM Identity Center.
To use the following example command, replace
with the ID of your
IAM Identity Center instance, 1234567890abcdef with your application
provider, and custom with a name
for your application.MyDataApplication
aws sso-admin create-application \ --instance-arn "arn:aws:sso:::instance/ssoins-ssoins-1234567890abcdef" \ --application-provider-arn "arn:aws:sso::aws:applicationProvider/custom" \ --nameMyDataApplication
Response:
{ "ApplicationArn": "arn:aws:sso::123456789012:application/ssoins-ssoins-1234567890abcdef/apl-abcd1234a1b2c3d" }
Create a trusted token issuer
Now that you have your IAM Identity Center application, the next step is to configure a trusted
token issuer that will be used to exchange your IdToken values from your
IdP with IAM Identity Center tokens. In this step you need to provide the following items:
-
The identity provider issuer URL
-
The trusted token issuer name
-
The claim attribute path
-
The identity store attribute path
-
The JSON Web Key Set (JWKS) retrieval option
The claim attribute path is the identity provider attribute that will be used to map to the identity store attribute. Normally, the claim attribute path is the email address of the user, but you can use other attributes to perform the mapping.
Create a file called oidc-configuration.json with the following
information. To use this file, replace the IssuerUrl value with the
issuer URL of your IdP, with
the IdP claim to map, preferred_username with the
identity store attribute to map it to, and
userName with your JWKS retrieval
option.OPEN_ID_DISCOVERY
{ "OidcJwtConfiguration": { "IssuerUrl": "https://login.microsoftonline.com/a1b2c3d4-abcd-1234-b7d5-b154440ac123/v2.0", "ClaimAttributePath": "preferred_username", "IdentityStoreAttributePath": "userName", "JwksRetrievalOption": "OPEN_ID_DISCOVERY" } }
To create the trusted token issuer, run the following command. To use this example
command, replace with the ID
of your IAM Identity Center instance and 1234567890abcdef
with a name for the trusted token issuer.MyEntraIDTrustedIssuer
aws sso-admin create-trusted-token-issuer \ --instance-arn "arn:aws:sso:::instance/ssoins-1234567890abcdef" \ --nameMyEntraIDTrustedIssuer\ --trusted-token-issuer-typeOIDC_JWT\ --trusted-token-issuer-configuration file://./oidc-configuration.json
Response
{ "TrustedTokenIssuerArn": "arn:aws:sso::123456789012:trustedTokenIssuer/ssoins-1234567890abcdef/tti-43b4a822-1234-1234-1234-a1b2c3d41234" }
Connect the IAM Identity Center application with the trusted token issuer
The trusted token issuer requires a few more configuration settings to work. Set the
audience that the trusted token issuer will trust. The audience is the value inside the
IdToken that's identified by the key and can be found in the identity
provider settings. For example:
1234973b-abcd-1234-abcd-345c5a9c1234
Create a file named grant.json that contains the following
content. To use this file, change the audience to match your identity provider settings
and provide the trusted token issuer ARN that was returned by the previous
command.
{ "JwtBearer": { "AuthorizedTokenIssuers": [ { "TrustedTokenIssuerArn": "arn:aws:sso::123456789012:trustedTokenIssuer/ssoins-1234567890abcdef/tti-43b4a822-1234-1234-1234-a1b2c3d41234", "AuthorizedAudiences": [ "1234973b-abcd-1234-abcd-345c5a9c1234" ] } ] } }
Run the following example command. To use this command, replace
with your account ID, and
111122223333 and
1234567890abcdef with the IDs in your
application ARN.abcd1234a1b2c3d
aws sso-admin put-application-grant \ --application-arn "arn:aws:sso::123456789012:application/ssoins-ssoins-1234567890abcdef/apl-abcd1234a1b2c3d" \ --grant-type "urn:ietf:params:oauth:grant-type:jwt-bearer" \ --grant file://./grant.json\
This command sets the trusted token issuer with configuration settings to trust the
audience in the grant.json file and link this audience with the
application created in the first step for exchanging tokens of the type
jwt-bearer. The string
urn:ietf:params:oauth:grant-type:jwt-bearer is not an arbitrary string.
It is a registered namespace in OAuth JSON Web Token (JWT) assertion profiles. You can
find more information about this namespace in RFC 7523
Next, use the following command to set up which scopes the trusted token issuer will
include when exchanging IdToken values from your identity provider. For
S3 Access Grants, the value for the --scope parameter is
s3:access_grants:read_write.
aws sso-admin put-application-access-scope \ --application-arn "arn:aws:sso::111122223333:application/ssoins-ssoins-111122223333abcdef/apl-abcd1234a1b2c3d" \ --scope "s3:access_grants:read_write"
The last step is to attach a resource policy to the IAM Identity Center application. This policy
will allow your application IAM role to make requests to the API operation
sso-oauth:CreateTokenWithIAM and receive the IdToken
values from IAM Identity Center.
Create a file named authentication-method.json that contains the
following content. Replace with
your account ID.123456789012
{ "Iam": { "ActorPolicy": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/webapp" }, "Action": "sso-oauth:CreateTokenWithIAM", "Resource": "*" } ] } } }
To attach the policy to the IAM Identity Center application, run the following command:
aws sso-admin put-application-authentication-method \ --application-arn "arn:aws:sso::123456789012:application/ssoins-ssoins-1234567890abcdef/apl-abcd1234a1b2c3d" \ --authentication-method-typeIAM\ --authentication-method file://./authentication-method.json
This completes the configuration settings for using S3 Access Grants with directory users
through a web application. You can test this setup directly in the application or you
can call the CreateTokenWithIAM API operation by using the following
command from an allowed IAM role in the IAM Identity Center application policy:
aws sso-oidc create-token-with-iam \ --client-id "arn:aws:sso::123456789012:application/ssoins-ssoins-1234567890abcdef/apl-abcd1234a1b2c3d" \ --grant-type urn:ietf:params:oauth:grant-type:jwt-bearer \ --assertionIdToken
The response will be similar to this:
{ "accessToken": "<suppressed long string to reduce space>", "tokenType": "Bearer", "expiresIn": 3600, "refreshToken": "<suppressed long string to reduce space>", "idToken": "<suppressed long string to reduce space>", "issuedTokenType": "urn:ietf:params:oauth:token-type:refresh_token", "scope": [ "sts:identity_context", "s3:access_grants:read_write", "openid", "aws" ] }
If you decode the IdToken value that is encoded with base64, you can see
the key-value pairs in JSON format. The key sts:identity_context contains
the value that your application needs to send in the sts:AssumeRole request
to include the identity information of the directory user. Here is an example of the
IdToken decoded:
{ "aws:identity_store_id": "d-996773e796", "sts:identity_context": "AQoJb3JpZ2luX2VjEOTtl;<SUPRESSED>", "sub": "83d43802-00b1-7054-db02-f1d683aacba5", "aws:instance_account": "123456789012", "iss": "https://identitycenter.amazonaws.com/ssoins-1234567890abcdef", "sts:audit_context": "AQoJb3JpZ2luX2VjEOT<SUPRESSED>==", "aws:identity_store_arn": "arn:aws:identitystore::232642235904:identitystore/d-996773e796", "aud": "abcd12344U0gi7n4Yyp0-WV1LWNlbnRyYWwtMQ", "aws:instance_arn": "arn:aws:sso:::instance/ssoins-6987d7fb04cf7a51", "aws:credential_id": "EXAMPLEHI5glPh40y9TpApJn8...", "act": { "sub": "arn:aws:sso::232642235904:trustedTokenIssuer/ssoins-6987d7fb04cf7a51/43b4a822-1020-7053-3631-cb2d3e28d10e" }, "auth_time": "2023-11-01T20:24:28Z", "exp": 1698873868, "iat": 1698870268 }
You can get the value from sts:identity_context and pass this information
in an sts:AssumeRole call. The following is a CLI example of the syntax.
The role to be assumed is a temporary role with permissions to invoke
s3:GetDataAccess.
aws sts assume-role \ --role-arn "arn:aws:iam::123456789012:role/temp-role" \ --role-session-name "TempDirectoryUserRole" \ --provided-contexts ProviderArn="arn:aws:iam::aws:contextProvider/IdentityCenter",ContextAssertion="value from sts:identity_context"
You can now use the credentials received from this call to invoke the
s3:GetDataAccess API operation and receive the final credentials with
access to your S3 resources.
Which grants match each sign-in type
When an application calls GetDataAccess, S3 Access Grants checks every grant
that could match the caller. This includes grants for the IAM role, the user,
the user's groups, and the user's attributes. For a user, S3 Access Grants checks grants that
use the user name and grants that use the IAM Identity Center user ID. For a group, S3 Access Grants
checks grants that use the group's display name and grants that use the IAM Identity Center
group ID. If a user signs in through IAM federation, grants that use an IAM Identity Center ID
and all group grants match only when your IAM identity provider is linked to an
IAM Identity Center directory. If more than one grant matches, the credentials are limited to the
most restrictive grant. For examples,
see Request access to Amazon S3 data through S3 Access Grants. The following table shows which
grants match for each sign-in type.
| Sign-in type | User grants by name | User grants by IAM Identity Center user ID | Group grants | Attribute grants |
|---|---|---|---|---|
| IAM federation, no IAM Identity Center directory | Yes | No | No | Yes |
| IAM federation with a linked IAM Identity Center directory | Yes | Yes | Yes | Yes |
| IAM Identity Center opted in to the simplified experience for trusted identity propagation | Yes | Yes | Yes | No |
| IAM Identity Center not opted in to the simplified experience for trusted identity propagation (requires an associated IAM Identity Center instance) | Yes | Yes | Yes | No |
Grants for the IAM role that the application uses match for every sign-in type, unless S3 Access Grants denies the request because it can't find the user in IAM Identity Center.
If your IAM identity provider is linked to an IAM Identity Center directory, or your IAM Identity Center instance is opted in to the simplified experience for trusted identity propagation, S3 Access Grants looks up the user in IAM Identity Center. If it can't find the user, it denies the request, and no grant applies, not even grants for the IAM role. Make sure that each user has an IAM Identity Center user name that matches their subject.
If your IAM Identity Center instance uses a customer managed AWS Key Management Service (AWS KMS) key, S3 Access Grants
looks up users and groups through Identity Store on behalf of the caller. The IAM
role that calls S3 Access Grants needs kms:Decrypt permission for the key, and
the key policy must allow Identity Store to decrypt with the key. These are the same
permissions that other services integrated with IAM Identity Center need. If a permission is
missing, the request fails. For more information, see Baseline KMS
key policy in the AWS IAM Identity Center User
Guide.
Per-user audit in AWS CloudTrail
AWS CloudTrail records the federated user for requests made with the session. The
userIdentity element of the event contains an
onBehalfOf element with the subject,
subjectType, issuer, and
federatedProviderArn of the user. If the IAM identity provider is
linked to IAM Identity Center, onBehalfOf also contains
identityStoreArn and
identityCenterInstanceArn. The userIdentity element
also contains a transactionContext element with the IdP claims that
IAM added to the session.
The following excerpt shows the userIdentity element of an event for
a request that the application made with the session from the earlier example.
"userIdentity": { "type": "AssumedRole", "principalId": "AROAEXAMPLEID:data-app-session", "arn": "arn:aws:sts::111122223333:assumed-role/data-app-role/data-app-session", "accountId": "111122223333", "accessKeyId": "ASIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AROAEXAMPLEID", "arn": "arn:aws:iam::111122223333:role/data-app-role", "accountId": "111122223333", "userName": "data-app-role" }, "webIdFederationData": { "federatedProvider": "arn:aws:iam::111122223333:oidc-provider/idp.example.com", "attributes": {} }, "attributes": { "creationDate": "2026-11-29T02:11:27Z", "mfaAuthenticated": "false" } }, "onBehalfOf": { "federatedProviderArn": "arn:aws:iam::111122223333:oidc-provider/idp.example.com", "subject": "00u1a2b3c4EXAMPLE", "subjectType": "user", "issuer": "idp.example.com" }, "transactionContext": { "IdentityProvider": { "department": "Finance" } } }