View a markdown version of this page

User-level access with trusted identity propagation - AWS Context

User-level access with trusted identity propagation

When an application or agent calls AWS Context on behalf of a user, AWS Context can propagate the user’s identity to your connections. Each connection can then return only the data that the user is authorized to access. This topic describes what AWS Context requires from the caller’s identity, and what each connection returns when AWS Context cannot use that identity. For how AWS Context receives the user’s identity, see IAM Identity Center for workforce users and SSO federation through corporate IdPs.

Trusted identity sources

AWS Context uses a user’s identity only when it trusts the identity source that issued the identity. An identity source is an IAM Identity Center identity store or an IAM identity provider.

AWS Context trusts the following identity sources:

  • Identity sources in the AWS account that owns the Agent Context. AWS Context always trusts these.

  • Identity sources that you add to the Agent Context’s trusted identity sources

For an IAM Identity Center user, AWS Context checks the account that owns the identity store. For a federated user, it checks the account that owns the IAM identity provider.

The following table shows the ARN that AWS Context checks for each identity type.

Identity type ARN that AWS Context checks Where to find the ARN

IAM Identity Center

The identity store ARN

The IdentityStoreArn value that the IAM Identity Center DescribeInstance operation returns

IAM federation

The ARN of the IAM identity provider that the user signs in through

The identity provider’s ARN in the IAM console

If AWS Context does not trust the identity source, it does not return an error. Amazon Bedrock Managed Knowledge Bases connections then return only documents that are not restricted by ACLs.

Your Agent Context’s resource policy controls which accounts and roles can call the Agent Context, and it does not need to name any identity source. If users from another account sign in through an identity source in that account, add the identity source to the trusted identity sources.

Trust identity sources in other accounts

To trust identity sources in other accounts, set the trustedIdentitySources member of a CreateAgentContext or UpdateAgentContext request. Each entry holds exactly one ARN, either as identityStoreArn or as identityProviderArn. The list can hold up to 100 unique entries, and each ARN must match exactly.

In UpdateAgentContext, the list that you send replaces the stored list, and an empty list removes every entry, which restores the default. If you omit the member, the stored list does not change. A change takes effect within a few minutes. GetAgentContext returns the stored list, and omits trustedIdentitySources when no entries are stored.

The following example shows a CreateAgentContext request body. The Agent Context maps one connection to an ontology, and trusts an identity store and an OIDC identity provider in account 111122223333.

{ "name": "sales-agent-context", "description": "Agent Context for the sales team", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "connectionMappings": [ { "connectionId": "arn:aws:context:us-east-1:444455556666:connection/conn-1234567890abcdef1234567890abcdef", "ontologyMappings": [ { "ontologyId": "arn:aws:context:us-east-1::ontology/data" } ] } ], "trustedIdentitySources": [ { "identityStoreArn": "arn:aws:identitystore::111122223333:identitystore/d-1234567890" }, { "identityProviderArn": "arn:aws:iam::111122223333:oidc-provider/example.com" } ] }

Identity requirements by connection type

The following table describes what each connection type needs from the user’s identity.

Connection type Identity requirement

Amazon Bedrock Managed Knowledge Bases

An email address, which AWS Context uses to filter documents by their access control lists (ACLs). For IAM Identity Center users, AWS Context uses the primary email address in the identity store, or the first email address if none is marked primary. For federated users, AWS Context uses the Subject when it is an email address, and otherwise the email runtime claim. The Subject type must be user. AWS Context does not recognize workload identities.

AWS Glue Data Catalog

The user’s identity, from IAM Identity Center or from IAM federation. AWS Lake Formation evaluates the permissions that you grant to the user and the user’s groups. These connections do not need an email address. For how to grant permissions, see Granting permissions on Data Catalog resources.

Third-party catalogs (Databricks Unity Catalog and Snowflake Horizon)

A user identity, from IAM Identity Center or from IAM federation. For federated users, the Subject type must be user. Each user signs in to the catalog when a response returns an authorization URL, and the catalog applies the permissions of the account that the user signs in with. These connections do not need an email address. The role that calls AWS Context needs glue:GetConnection and glue:ManagedConnector for the catalog’s AWS Glue connection, which must be in the caller’s account. For a caller in another account, AWS Context does not return the catalog’s results.

Allow data access roles to receive user identities

To pass a user’s identity to a connection, AWS Context asks AWS Security Token Service (AWS STS) to attach the identity to the data access role session. If your users sign in through an IAM Identity Center instance that uses the legacy experience of trusted identity propagation, add sts:SetContext to the trust policy statement that allows AWS Context to assume the data access role, so that the statement allows both sts:AssumeRole and sts:SetContext. For the simplified experience and for IAM federation, AWS STS allows sts:SetContext implicitly, so you do not need to add it.

Within the TIP propagation boundary, an explicit Deny for sts:SetContext, such as one in a resource control policy (RCP), makes the role assumption fail, even when the trust policy allows sts:SetContext.

If AWS STS refuses to attach the identity, AWS Context does not return an error. Instead, the connection returns the following:

  • Amazon Bedrock Managed Knowledge Bases connections – SearchAgentContext and TraverseAgentContext return no documents from the knowledge base. AgenticRetrieve returns only documents that are not restricted by ACLs.

  • AWS Glue Data Catalog connections – AgenticRetrieve does not read the source. ExecuteSql runs the query with the Lake Formation grants of the data access role. Grant each data access role access only to data that every caller can see.

For more information about sts:SetContext, see Control TIP for IAM federation with IAM policies.

When AWS Context cannot use the user’s identity

Review these cases when users report missing results.

The identity source is not trusted

The identity source is in another account, and it is not in the Agent Context’s trusted identity sources. Amazon Bedrock Managed Knowledge Bases connections then return only documents that are not restricted by ACLs. Other connection types are not affected.

To resolve this issue, add the identity source’s ARN to the trusted identity sources. Or use an identity source in the account that owns the Agent Context. For details, see Trusted identity sources.

The user’s identity does not include an email address

This case affects only Amazon Bedrock Managed Knowledge Bases connections, which then return only documents that are not restricted by ACLs. AWS Glue Data Catalog connections and third-party catalogs do not use an email address, so they accept a Subject that is not an email address.

This case applies in the following situations:

  • An IAM Identity Center user has no email address.

  • A federated user’s Subject is not an email address, and the session has no email runtime claim.

To add the email address for federated users, configure TIP on the IAM identity provider that your callers use. Then do one of the following:

  • Add a runtime-claim mapping with the target key email.

  • Map a claim that contains the user’s email address to the Subject.

For more information about runtime claims, see TIP context keys and runtime claims for IAM federation.

AWS CloudTrail (CloudTrail) records the Subject and runtime claims of TIP sessions, including any email address that you map. Limit who can read your CloudTrail logs.

Important

Map an email attribute that your identity provider manages and verifies. If users can change the attribute, a user can enter another user’s email address and receive that user’s documents.

The federated user’s Subject type is not user

If a federated user’s session has no Subject type, or a Subject type other than user, Amazon Bedrock Managed Knowledge Bases connections and third-party catalogs handle the request as a request without a user. This applies even when the session includes an email address. For AWS Glue Data Catalog connections, AWS Context still asks AWS STS to attach the identity to the data access role session.

To resolve this issue, set the Subject type to user in the TIP configuration of the IAM identity provider. For details, see SSO federation through corporate IdPs.

The table’s location is registered with the Lake Formation service-linked role

If your IAM Identity Center instance uses the legacy experience of trusted identity propagation, IAM Identity Center users cannot read AWS Glue Data Catalog tables whose Amazon S3 location is registered with the Lake Formation service-linked role. The read fails with an access denied error, and nothing is read through the data access role.

To resolve this issue, register the location with a custom IAM role whose trust policy allows sts:SetContext. For the role requirements, see Requirements for roles used to register locations.

The user signs in with a permission set in the legacy experience

If your IAM Identity Center instance uses the legacy experience of trusted identity propagation, AWS Context does not read AWS Glue Data Catalog connections for a user who calls it with a session from a permission set. AgenticRetrieve skips these connections, and ExecuteSql and StartEvaluation return an access denied error. If the Agent Context has no other connections, AgenticRetrieve also returns this error.

We recommend that you turn on the simplified experience of trusted identity propagation for your IAM Identity Center instance. With the simplified experience, sessions from permission sets carry the user’s identity. Turning it on doesn’t disrupt your existing applications or sign-in flows. For details, see Enable the simplified experience and Moving from the legacy experience to the simplified experience.

If you keep the legacy experience, call AWS Context with an identity-enhanced role session instead. Your application calls the IAM Identity Center CreateTokenWithIAM operation to get an ID token for the user. It then calls AssumeRole and passes the sts:identity_context claim from the ID token in ProvidedContexts. For details, see Set up trusted identity propagation.

AWS STS does not attach the identity to the data access role session

AWS STS can refuse or drop the user’s identity when AWS Context assumes a data access role:

  • A policy refuses `sts:SetContext` – For the required permissions and the result, see Allow data access roles to receive user identities.

  • The role is outside the TIP propagation boundary – For IAM federation and for the simplified experience of IAM Identity Center trusted identity propagation, AWS STS attaches the identity only if the data access role is in the identity source’s account, or in another account in the same organization. Otherwise, AWS STS drops the identity, and the AssumeRole call still succeeds. AgenticRetrieve does not read AWS Glue Data Catalog sources. ExecuteSql runs the query with the Lake Formation grants of the data access role.

For these identity types, this case applies whenever the identity source is in an account outside the organization of the account that owns the data access role, whether or not the identity source is in the Agent Context’s trusted identity sources. If the identity source’s account is not in an organization, it applies whenever the data access role is in another account.

To check whether AWS STS dropped the user’s identity, complete the following steps:

  1. In the account that owns the data access role, find the AssumeRole event for the role in AWS CloudTrail.

  2. Check the additionalEventData.trustedIdentityPropagationSuppressed field. A value of true means that AWS STS dropped the identity. The field is absent when AWS STS attached the identity.

For more information about the boundary, see Understand where TIP context propagates and Logging TIP activity with AWS CloudTrail.

Data returned without an email address or a user identity

The following table describes what each connection type returns when the user’s identity has no email address, and when the request has no user identity, such as a request made with IAM credentials without TIP.

Connection type The user’s identity has no email address The request has no user identity

Amazon Bedrock Managed Knowledge Bases

Only documents that are not restricted by ACLs

Only documents that are not restricted by ACLs

AWS Glue Data Catalog

Results for the user. These connections do not use the email address.

With a data access role, the data that Lake Formation grants to that role, including data granted to the IAMAllowedPrincipals group. Without a data access role, the data that Lake Formation grants to the caller’s IAM principal. This data can be more or less than the user can access.

Third-party catalogs

Results for the user. These catalogs do not use the email address.

No data. The catalog returns data only for a user who has signed in to it.

Important

Without a user identity, Lake Formation evaluates the connection’s data access role, not the user. When the connection has no data access role, Lake Formation evaluates the caller’s IAM principal. Grant each AWS Glue Data Catalog data access role access only to data that every caller can see.

To keep that data limited, revoke the permissions that are granted to the IAMAllowedPrincipals group on those databases and tables. Before you revoke them, grant Lake Formation permissions to the other principals that read those databases and tables, because they lose access too. For details, see Upgrading AWS Glue data permissions to the AWS Lake Formation model.

Best practices

  • Use identity sources in the account that owns the Agent Context, or add them to the trusted identity sources.

  • If your IAM Identity Center instance uses the legacy experience, add sts:SetContext to the trust policy of each data access role.

  • For IAM federation, set the Subject type to user, and map a verified email address to the Subject or to the email runtime claim.

  • Grant each AWS Glue Data Catalog data access role access only to data that every caller can see.

  • If several connections reach the same data, give them the same access setting, or create the mapping of the connection whose setting you want first. For more information, see When several connections reach the same data.

  • For third-party catalogs, have each user complete the sign-in when a response returns an authorization URL. Until a user signs in, those catalogs return no data for that user.