aws-samples / aws-iam-identity-center-extensions

This solution is intended for enterprises that need a streamlined way of managing user access to their AWS accounts. Using this solution, your identity and access management teams can extend AWS SSO functionality by automating common access management and governance use cases
MIT License
65 stars 24 forks source link

Session duration as a parameter? #37

Open allquixotic opened 2 years ago

allquixotic commented 2 years ago

Hi, we'd like to be able to specify the maximum session duration of the LinkCallerRole and PermissionSetCallerRole in the parameters (env.yaml). The 1 hour default session expiration makes it difficult to even demo the APIs because of the effort it takes to setup Postman after getting a session token.

We'd probably keep it at a reasonably lower level once we have full automation and have implemented an automated consumer of the APIs, but for dev/test, the 1 hour session duration is very challenging to work with.

Despite IaC best practices, I've manually hacked the max session duration to 12 hours on the roles for now. I'm thinking cross-account-role.ts can be modified where the new Role constructor is invoked, to bring in a parameter from the configuration to optionally edit the session duration.

leelalagudu commented 2 years ago

Hi @allquixotic ,

Thank you very much for your continued support and feedback. We did consider this as a configuration parameter earlier, but did not go through for the following reason:

Is your preference to assume the caller roles directly rather than role chaining? If so, I can extend the configuration parameters with the caveat that this would only be applicable in case of direct role assuming.

Let me know if this fits in with your requirements and I will go ahead with the PR.

Thank you, Leela

allquixotic commented 2 years ago

Hi,

I am indeed accessing the caller roles through another IAM role, using sts assume-role. The API key I use to perform the assume-role is a temporary session (I've manually set the Permission Set to 12h) that I get through AWS SSO - figured I might as well use the feature that the end-users will be saddled with once this is rolled out.

So with the role and the permission set both manually having their session expiration set to 12 hours, I can successfully request a 12 hour credential set from aws sts assume-role.

Every time I do this, I have to:

  1. Log out of Okta
  2. Log into Okta
  3. Go to the AWS SSO chiclet
  4. Select the OrgMain account and click Console access
  5. Copy the API key, access key and secret access key to ~/.aws/credentials on the EC2 box I use for SSOEx dev/bootstrapping; these are valid for 12 hours
  6. Use aws sts assume-role to get credentials for the caller roles; these are also valid for 12 hours now that I've manually set it up that way
  7. Copy the six fields (2 x access key, secret access key and session token) into the Postman environment

Only then can I finally issue API requests in Postman. If I had to do this every hour, I would go slightly insane. As it stands, it's a daily chore.

I'm a lazy sysadmin; that's why I went into a job in the DevOps field :) As you can imagine, I would prefer to automate this repetitive workflow. If you have any suggestions on that or best practices, I would appreciate it.

I'll leave it to your discretion to decide whether it makes sense to add the session duration as a parameter based on my input here. I don't want to dictate how your product should work. It just seems to be useful in my use case.

Thanks for working on this!

leelalagudu commented 2 years ago

I think you've convinced us with your 7 step workflow there @allquixotic :) :) ..

As it would be a config driven parameter and not a huge change, we will go ahead with including this ability. I will update here once the PR is merged.

And, thank you once again for all the helpful feedback.

leelalagudu commented 2 years ago

Hi @allquixotic ,

I was looking into this in more detail to include the change as part of the PR and I think I misunderstood the ask earlier.

6. Use `aws sts assume-role` to get credentials for the caller roles; these are also valid for 12 hours now that I've manually set it up that way

Can you confirm if the credentials you are vending in this step are valid for 12 hours?

allquixotic commented 2 years ago

I made an error in the above. After hitting the 1 hour role chaining limit with the SSO based sign-on, I used my personal IAM account into the OrgMain account, and get the credentials based off of that. So I'm not using role chaining in practice. That's why increasing the session expiration in the role actually does help me. :)

leelalagudu commented 2 years ago

Aah, that explains my confusion then.

Does this approach work for you?

allquixotic commented 2 years ago

This works for me! Thank you. :)

leelalagudu commented 2 years ago

@jmejco to investigate and validate if this falls under the role chaining limitation (i.e. 1 hour duration) / if a configurable session time out can be provided.