View a markdown version of this page

SSO federation through corporate IdPs - AWS Context

SSO federation through corporate IdPs

Your organization might sign users in through a corporate identity provider (IdP), such as Okta or Microsoft Entra ID. This topic describes how to pass those users' identities to AWS Context through IAM federation. You turn on trusted identity propagation (TIP) for the IAM SAML or OpenID Connect (OIDC) identity provider that represents your IdP. Your application then calls AWS Context with the role session that each user federates into.

How AWS Context receives the user’s identity

The user signs in through an IAM SAML or OIDC identity provider that has TIP turned on. The role session’s credentials identify the user in the aws:OriginIdentity/Subject context key, and can carry runtime claims under aws:TransactionContext/IdentityProvider/.

Amazon Bedrock Managed Knowledge Bases connections filter documents by the user’s email address. The aws:OriginIdentity/Subject key or the aws:TransactionContext/IdentityProvider/email runtime claim must contain that email address, so configure TIP on the identity provider to supply it.

When AWS Context assumes a connection’s data access role, it asks AWS Security Token Service (AWS STS) to attach the user’s identity to the role session. Connections that read data through that role session then receive the user’s identity.

Set up IAM federation for AWS Context

Before you begin, create an IAM SAML or OIDC identity provider for your IdP, and an IAM role that your users federate into. The role’s trust policy allows sts:AssumeRoleWithSAML or sts:AssumeRoleWithWebIdentity for the identity provider. You do not add sts:SetContext to this trust policy, because AWS STS allows it implicitly when users federate. If your application calls AWS STS through a VPC endpoint whose policy lists allowed actions, that policy must also allow sts:SetContext. The role’s permissions policy must allow the AWS Context operations that your application calls.

Create the identity provider in the account that owns the Agent Context, or add its ARN to the Agent Context’s trusted identity sources. For details, see Trusted identity sources. If the role that users federate into is in another account, the Agent Context’s resource policy must also allow that role.

To set up IAM federation for AWS Context, complete the following steps:

  1. Turn on TIP for the identity provider, and choose a Subject that is stable and unique for each user. For which value to choose, see How TIP for IAM federation uses identity information. TIP applies to every session that federates through this identity provider. If the provider is already in use, make sure that every SAML assertion or OIDC token contains the Subject, and a valid value for each claim that you map. Otherwise, AWS STS rejects the sign-in.

  2. Set the Subject type to user. Without this Subject type, Amazon Bedrock Managed Knowledge Bases connections and third-party catalogs handle the request as a request without a user.

  3. If you use Amazon Bedrock Managed Knowledge Bases connections, make sure that each session carries the email address that your documents' ACLs use. When the Subject is an email address, AWS Context uses the Subject and ignores the email runtime claim. Otherwise, add a runtime-claim mapping with the target key email. Map a verified email attribute that users cannot change.

  4. If you grant AWS Lake Formation permissions to groups, configure group-based access for the identity provider. Group-based access associates an IAM Identity Center instance with the identity provider, so that AWS services can find each user’s groups in it. The Subject must match each user’s Username in IAM Identity Center, and the users and groups must exist in that instance’s identity store. You do not need group-based access to grant permissions to individual users.

  5. In your application, federate each user into the IAM role with AssumeRoleWithSAML or AssumeRoleWithWebIdentity.

  6. Call AWS Context with the role session.

After you complete these steps, AWS Context receives each federated user’s identity and propagates it to your connections.

Then grant your users access in each source:

  • For Amazon Bedrock Managed Knowledge Bases connections, name each user in the ACLs of restricted documents by the email address that the user’s session carries.

  • For AWS Glue Data Catalog connections, grant Lake Formation permissions to each user’s Subject value exactly as your IdP sends it, or to the user’s groups. For details, see Granting permissions on Data Catalog resources.

  • For third-party catalogs, you do not map users. The first time that a request needs data from Databricks Unity Catalog or Snowflake Horizon for a user, the response returns an authorization URL. The user signs in to the catalog there, and the catalog applies the permissions of the account that the user signs in with. For details, see Snowflake and Databricks: identity mapping.

For more information about TIP for IAM federation, see Configure TIP for an IAM identity provider and Configure group-based access for TIP.