-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[v2] Session Duration of Permission Set is not respected by AWS CLI #7104
Comments
Hi @hamsec-aumni thanks for reaching out. Here is documentation on SSO that I think addresses the behavior you’re describing: https://docs.aws.amazon.com/singlesignon/latest/userguide/authconcept.html
So the default is an 8-hour session but you can customize the permission set session duration as you mentioned. Are you saying the CLI behavior is inconsistent with that documentation or that the SSO design is the issue? |
Thanks for your response @tim-finnigan. It seems that the CLI behavior is inconsistent with that documentation. It doesn't seem to be an issue with SSO service because the console access does respect the session duration (if 1 hour it times out after 1 hour and the user needs to sign in again). Regardless of the session duration I set in the Permission Set the CLI session is always 8 hours. |
@tim-finnigan just wanted to bump this before this moves to "closing-soon". And to just to be clear the CLI behavior is inconsistent with that documentation as the CLI always requests the default 8 hour session regardless of what is set in the permission set. |
@tim-finnigan just checking in to see if there's anything else I can do to help your investigation on this. Do you need any additional configuration information? |
Hi @hamsec-aumni thanks for following up. I'm still not sure if the behavior you're describing is inconsistent with the documentation shared earlier. For further explanation I found this knowledge center article and blog post. Have you tried authenticating with SSO and confirming that you still have permissions after their designed expiration time? |
I think you're right @tim-finnigan that I was confusing the expiry time value
The timestamp above is one hour from when I run that command, so the credentials returned if used would respect the Permission Set duration. However, it's still an issue because it would seem with every aws command that leverages the IAM Identity Center (successor to AWS SSO) configured profile, makes a call against STS to perform the This is why when I configure my local SSO Profile Does that make sense? |
@tim-finnigan I think I found the documentation that explains exactly what I'm seeing and contradicts the documentation I referenced in my initial reporting of this issue. In the setup guide for configuring AWS CLI to use AWS IAM Identity Center (successor to AWS Single Sign-On) it says:
And per the blog post you shared, the cached credentials stored at So when this documentation regarding setting the session duration says:
It is misleading because although technically the role credentials returned (hidden to the user) when running any CLI command do respect the permission set, as soon as the role credentials expire AWS CLI will automatically renew them. Therefore, to the end user and effectively when running AWS CLI commands the access duration is always 8 hours irrespective of what's set in the permission set. So I guess the only action item for you would be to request that this documentation be updated to properly reflect that. Does this make sense? Furthermore do you know where else I could report this that might get this code redesigned to have AWS CLI effectively respect the session duration of permission sets? |
I think I'm running into a similar instance of this issue. Since the aws-cli auto-refreshes the credential, I can usually run cli commands all day long without re-running |
Thanks for following up and providing more information, I've just had a chance to revisit this. I agree that the documentation could be clarified in this case. I created an internal ticket for the Identity Center team to look further into what needs to be updated and I'll post an update here when I hear back. In the meantime if your team is blocked by any service-related behavior we recommend reaching out through AWS Support for a more direct channel of communication. |
Thanks @tim-finnigan. We have workarounds in place for the time being and look forward to hearing what the Identity Center team says. |
Just also got hit by this with terraform, and at first suspected an issue within terraform: hashicorp/terraform#31943 But indeed, while my PermissionSet was configured for 12 hours lifetime, the CLI wrote an |
Yeah, this is something that also affects us. Since |
While I closed hashicorp/terraform#31943 now, another participant and I did some more experiments. Apparently there are two different accessToken formats issued seemingly at random. Either a more "JWT"-like structure, or a shorter binary structure. I could not yet determine a system behind it, it seems random. And after using SSO more intensively the last few days, sometimes the shorter variant of the token expires even faster than 8 hours, also long before |
We've also noticed in the past couple of days that the expiresAt is not respected and usually requires re-auth in around an hour. |
This is likely related to #7340 which has since been resolved. Regarding the original questions directed to the SSO team, here is the response we received: This statement from the documentation: "When the AWS Command Line Interface (CLI) is used, AWS SSO uses the session duration setting on the permission set to control the duration of the session" is correct. Checking the access token which will always be 8 hours only. To check the permission set equivalent duration you need to check the file in the location @hamsec-aumni please let us know if you had any follow up questions or feedback on this. |
Checking in as we haven't heard back in a few weeks. I'm going to close this since the behavior seems expected and the SSO team confirmed. Please refer to the comment above if you have any additional feedback on this issue. |
|
I don't think this was related to #7340, as it predated that issue by quite a long while, and has different symptoms. And while this may be "expected behavior" that does not mean it is correct or desirable. It does seem there are improvements that could be made, to align the expiration and behavior across tools and SDKs, to make a better user experience. |
I also don't think the original issue relates to #7340 but some people commented here around the time that issue was created and I think conflated the two. Going forward we can pass along feedback to the SSO team if anyone wants to share any suggestions, or you could consider opening a case through AWS Support for more direct correspondence. We're also tracking cross-SDK feature requests here in a shared repository. But in this case I think the feedback here is for improvements to the functionality or documentation of SSO itself. |
I don't understand why the |
To others who might find this ticket – it looks like this works as expected when using the newer |
This is still impacting me. It was setup manually. Ex:
Session duration is set to more than 1 hour. |
Describe the bug
When our users login via the AWS CLI using
aws sso login
the session duration is always 8 hours regardless of what the session duration is set in the corresponding permission set.Expected Behavior
Per this documentation:
It is expected that what the Permission Set has for Session Duration should match the length of the session when using the AWS CLI
Current Behavior
Regardless if the Permission Sets Session Duration is set to 1, 2, 4, 12 hours or even Custom. When authenticated via AWS CLI it always returns an 8 hour session.
Reproduction Steps
Setup AWS SSO with IdP of choice
Configure Permission Set with a session duration at 1 hour:
Assign a Permission Set to an SSO user and AWS Account
The user configures their SSO profile in aws cli via
aws configure sso
and chooses the role corresponding to the above permission setUser is successfully logged in:
accessToken
expires:Possible Solution
No response
Additional Information/Context
This is a very big security concern as we can't have sessions for more permissive roles set to the minimum of 1 hour. Could be a backend issue for the SSO Service team per this closed issue
CLI version used
aws-cli/2.7.14 Python/3.9.11 Darwin/21.5.0 exe/x86_64 prompt/off
Environment details (OS name and version, etc.)
macOS 12.4 (21F79)
The text was updated successfully, but these errors were encountered: