Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the customRoleArn (#1125) #7631

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

HOLTHOJ
Copy link

@HOLTHOJ HOLTHOJ commented Jan 27, 2021

Fixes: #1125

Description of changes:

The application can specify the role to assume, which will override/bypass the configured logic in the Identity Pool.
https://docs.aws.amazon.com/cognito/latest/developerguide/role-based-access-control.html#using-tokens-to-assign-roles-to-users

A customRoleArn property has been added to the Auth configuration object

This property is a function so that applications can first evaluate the ID token before making a role selection (e.g. lookup the available roles in the cognito:roles attribute).

Another use case might be that an application contains multiple security zones (e.g. www.enterprise.com/public and www.enterprise.com/private). The role to assume is defined based on the zone the user is in.

Another similar use case might be a splash screen that allows you to login into different accounts. For this the role to assume also needs to be dynamically calculated.

All calls to GetCredentialsForIdentity have been updated

If the property is provided, the function will be evaluated when the request for credentials is made.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The application can specify the role to assume, which will override/bypass the configured logic in the Identity Pool.

https://docs.aws.amazon.com/cognito/latest/developerguide/role-based-access-control.html#using-tokens-to-assign-roles-to-users
@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #7631 (f575d74) into main (104b278) will decrease coverage by 0.01%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7631      +/-   ##
==========================================
- Coverage   74.07%   74.06%   -0.02%     
==========================================
  Files         214      214              
  Lines       13410    13414       +4     
  Branches     2628     2631       +3     
==========================================
+ Hits         9934     9935       +1     
- Misses       3277     3280       +3     
  Partials      199      199              
Impacted Files Coverage Δ
packages/auth/src/types/Auth.ts 100.00% <ø> (ø)
packages/core/src/Credentials.ts 34.13% <0.00%> (-0.42%) ⬇️
packages/auth/src/Auth.ts 88.19% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 104b278...f575d74. Read the comment docs.

@ahmed-sharief5
Copy link

Hi @elorzafe, Could you please review and merge this PR. As our development work is dependent on this feature.

@siegerts siegerts added the first-time-contributor The contribution is the first for this user in the repo label Jul 30, 2021
@austinwu
Copy link

Hello @elorzafe @sammartinez @ashika01 would it be possible to consider this PR?

@dls314
Copy link

dls314 commented Jul 12, 2022

Hi @elorzafe, Could you please review and merge this PR? It would resolve an open AWS support ticket that we have.

@ashika01
Copy link
Contributor

@HOLTHOJ @dls314 Apologies on not getting back on this sooner. Can we get the merge conflicts resolved and possibly add tests for this use case?

@elorzafe
Copy link
Contributor

Apologies for not looking into this issue until now. I will be looking the security implications of this.

@elorzafe
Copy link
Contributor

@HOLTHOJ

Thanks for this PR, I am reviewing it now. (Apologies for taking that long)

I have a question for this change, what about the option of using Pre token generation lambda trigger to modify the token groups based on client Metadata? I am not closed to merge this, just trying to understand more why you prefer to do this on the client instead of a lambda?

@HOLTHOJ
Copy link
Author

HOLTHOJ commented Aug 31, 2022

Hi @elorzafe ,

It's been a while since I looked into this,
But this is a feature from the underlying AWS api, so we should not restrict users from using it.

From what I recall there are two scenarios;

For the client side I described some scenarios in my opening comment.

On the flip side, there doesn't seem too much demand/support for this. I also think Identity pools are simply not used that much anymore. Especially since you can do third-party signins with the user pool as well.

@elorzafe
Copy link
Contributor

@HOLTHOJ

Thanks for replying so quickly!

I understand that you would like to use features that the underlying AWS SDK has, we could provide an escape hatch to support this feature in the future. But I am not convinced we should make it part as a core feature on the category itself.

Do you have experience working with other AuthN providers on how they solve this issues?

Thanks again!

@KevinToala
Copy link

in our application this functionality would be very important, thanks

@manueliglesias manueliglesias requested review from a team as code owners September 30, 2022 21:21
@cwomack cwomack added the Auth Related to Auth components/category label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category external-contributor first-time-contributor The contribution is the first for this user in the repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants