- Newest
- Most votes
- Most comments
Based on the information provided, it appears you're facing some limitations with the IAM trust policy for OIDC federation using Keycloak. You're correct that the current IAM implementation for web identity federation primarily allows filtering based on 'aud', 'sub', and 'email' claims.
For your specific questions:
-
Unfortunately, filtering access based on Keycloak roles directly in the IAM trust policy is not supported out-of-the-box. The IAM service doesn't have built-in support for custom claims like roles from Keycloak in the trust policy.
-
Your conclusion about needing multiple clients for different groups of users is a common workaround, although it can indeed be cumbersome to manage.
However, there are a few alternative approaches you could consider:
-
Use the 'sub' claim: If your Keycloak setup allows for unique 'sub' claims for different roles or groups, you could use that in your trust policy.
-
Implement a custom solution: You could create a Lambda function that acts as an intermediary. This function could verify the Keycloak token, check the roles, and then assume the appropriate AWS role.
-
Use Amazon Cognito: If possible, you could integrate Keycloak with Amazon Cognito. Cognito has more flexible support for mapping custom attributes to IAM roles.
-
Use AWS SSO (Single Sign-On): If feasible for your use case, AWS SSO provides more granular control over role assignments based on identity provider attributes.
While these aren't direct solutions to using Keycloak roles in the IAM trust policy, they offer alternative ways to achieve role-based access control with OIDC federation. The limitation you've encountered is a known constraint of the current IAM implementation for web identity federation.
Sources
AssumeRoleWithWebIdentity - AWS Security Token Service
IAM and AWS STS condition context keys - AWS Identity and Access Management
answered 2 years ago
Relevant content
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
