-
Notifications
You must be signed in to change notification settings - Fork 15
SSO session expiration and re-login #531
Comments
Hi @villelahdenvuo thanks for reaching out. Per this documentation: "Each time a user signs in to IAM Identity Center, a sign in session is created with an 8-hour lifetime." Regarding what you said here:
How much more time do you have to wait in this scenarios? |
I'm also seeing the same issue as @villelahdenvuo. |
@michelleparent which version of the AWS CLI are you using? There was a recent issue involving SSO and it looks like the issue creator was also using v2.8.2 like @villelahdenvuo. I recommend updating to the latest version (currently 2.8.6 per the CHANGELOG) and let us know if you're still seeing the issue. |
@tim-finnigan I upgrades to v2.8.7 and I'm still seeing the issue. I tried clearing my SSO cache in |
@tim-finnigan I would say waiting around 5-10 minutes was enough, but it's a very annoying disturbance to development because I cannot use my development environment during that time. I will update to the latest version and keep trying, but like you said it only happens after 8 hours so it's not something that happens every day. |
You're right about the cause. It's the session that remains active on the portal, but somehow the generated tokens are already expired a bit sooner. If I clear the cookies on the portal page I do get a new expiresAt value, so that can potentially help as a workaround, but still an annoying disturbance to experience. |
@michelleparent are you still experiencing this issue? If so could you add share your debug logs with sensitive info redacted by adding Thanks @villelahdenvuo for the feedback, I can forward your comments to the SSO team - please let me know if there's anything you'd like to expand on. You could also consider reaching out through AWS Support for further assistance. |
I had the same issue. I confirm that clearing the cookies for Version info:
|
Based on the recent comments I think this issue can now be closed. If there's any other feedback to share regarding this please let us know. Thanks! |
|
@tim-finnigan I wouldn't say this issue can be closed, perhaps it needs to be moved to another project? The problem still persists, clearing the cookies is not a good workaround since it still breaks the development workflow. The tokens should just work or the CLI should tell me to sign in again, not tell me token is expired and provide me no way to refresh it (until I wait or clear cookies manually). |
@villelahdenvuo thanks for following up. I can transfer this to our cross-SDK repository to track as a feature request for the SSO team. If you could summarize the request then I'll do that and forward your feedback to that team. |
@tim-finnigan It's difficult to summarize concisely, but here's an attempt: Ensure that AWS SDK and AWS CLI token expiration & refresh logic work together properly with an AWS SSO session. Currently SDK token can expire while the SSO session is still valid causing a problem where SDK says expired and CLI says you're good to go when you try to do a |
We experienced this problem too. Having to clear cookies works but is not a practical solution. Hopefully this gets looked at. |
Thanks @villelahdenvuo for following up. I'm now wondering if what you're describing overlaps with other previous issues such as aws/aws-cli#5955. Can you describe your SSO configuration and confirm? The guidance in this comment specifically may be helpful. Please let us know. |
@tim-finnigan No, we're using a barebones SSO setup for example:
With |
I don't know if this is related, but I'm on Windows and when the Permission Set session expires, Python CDK often returns |
I reached out to the SSO team to try and get more context on this issue. Still waiting to hear back but will update the issue when I have more information. I'll also link a couple more relevant documentation pages that I didn't see referenced yet: CLI User Guide: https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html
CLI command reference for
|
This is presumably a service-side issue. It's not possible for the CLI to update the token in the cache without updating the expiration. The cache entry is formed from the service response and then put in the cache in its entirety. So if there's a mismatch, it may be that the service (i.e., the |
Yeah this happens all the time for us. Both in node sdk and also with cdk. Thanks to this issue we now have a work around of clearing the cookies and forcing a new session on the console to be generated. But this is obviously a mis-matched expiration issue and should not be this difficult to address. |
I suspect that this might have something to do with the issue: If the credentials will expire within the next 15 minutes, they're flagged as already expired. If |
I just briefly had this same exact experience, when using git cli and attempting 'git pull'.
|
when running For now, I'm having to manually update the credentials after logging in via my login url before running |
incredible - this has been driving me crazy forever found that if I logout of SSO in the browser it'll force a refresh - only way to get out of that limbo |
There is so much noise and incorrect information in this thread. To clarify what's happening and why this isn't a bug in the CLI (but rather a mismatch between some SDKs and the Identity Center service—which still needs to be resolved!) let me run through the entire process:
Ok, so now you've got a valid token on your system. Let's look at what happens when attempt to make an API call with the CLI, like
So while it will attempt to refresh the token before the expiration, but the only thing that actually says "this token is expired" when you call AWS with the token to get credentials for a specific account and role and AWS responds that the token is invalid, which only happens when the session (and token) is actually expired (which is the behavior you'd expect and want). As @nwalters512 pointed out, the JS SDK is too eager on this front. Instead of using that 15 minute window to attempt credential refresh, it just considers it expired and does not attempt to get credentials. As per aws/aws-sdk-java-v2#3679, the Java SDK has the same logic. To see why When Only once the browser does not hold cookies for a valid session (either because the cookies are gone or the session is no longer valid) will Identity Center re-authenticate you, creating a new session with a new expiration, and then the token returned by CreateToken will have that new expiration. This is why logging out in your browser works; there's no longer a valid session to use, so when So the mismatch here is between SDKs (the JavaScript v3 SDK, the Java SDK, and possibly others) that refuse to use a token that is within 15 minutes of its expiration, and the Identity Center |
A huge thanks to @benkehoe for identifying and explaining the issue. I think much of the original confusion here comes down to inconsistent behavior between SDKs, despite expected behavior on the CLI side. Because this is a cross-SDK issue, I'm going to transfer it to our shared SDK repository for tracking going forward. We have raised this issue internally and currently are in discussions with the service team. Further investigation is needed to determine the best path forward. We will update this issue when we have more information. Thanks all for your patience and contributions here thus far. |
For the record, my position is that SDKs should not refuse to use a token that hasn't expired yet. An expiration window is great for refreshing credentials so that there's no gap where the SDK only has expired credentials, but it just doesn't make sense to be like "well, this might not work in 15 minutes, so better stop using it now". |
Just want to raise here that the issue mentioned ☝️ regarding Want to ensure that it's not a related issue that may not be fixed with any fix created for this. Other threads had surmised that using the Thank you to @benkehoe for the detailed breakdown of the flows involved. If anyone happens to know of any workarounds until this is solved, it would be wonderful. The issue of there being a 15 minute window of the system saying the token is invalid, but also not allowing a new one to be refreshed is not what we're hitting, but rather our sessions being always 1 hour long no matter what I have them set to within the Permission Set (12 hours). |
@spoco2 a workaround I found is to run any command with aws-cli on the sso-session profile before using cdk (something simple like |
@gastonsilva , thanks. I was thinking something like that, or a cron job to do that every 10 minutes or so would be something to keep it alive in the meantime! |
Noting here that this has been fixed in Java SDK v2.20.100: aws/aws-sdk-java-v2#3679 (comment) Since this is no longer a cross-SDK issue but a JavaScript SDK issue, I think we should continue tracking here going forward:
|
This issue is now closed. Comments on closed issues are hard for our team to see. |
@tim-finnigan Just to confirm, have all the other AWS SDKs been checked for this problem? |
@benkehoe Yes we had members from each SDK team review and confirm, only the Java and JavaScript SDKs were found to have this issue. |
I had the same issue. I'm using ARC browser and the Whenever the That did the trick for me! |
Does anyone know anything about when the sso session will expire |
Describe the bug
I'm using AWS SSO to authenticate and aws-sdk-js-v3. When the SSO session expires it tells me to log in again with an error message, but even after repeating the aws sso login, the credentials still don't work.
Expected Behavior
The Node server is able to load credentials again and I can keep developing.
Current Behavior
The error message persists.
Reproduction Steps
aws sso login --profile developer
AWS_PROFILE=developer node server.js
aws sso login --profile developer
Possible Solution
No response
Additional Information/Context
I opened my
.aws/sso/cache/xxx.json
file and notice that theaccessToken
is updated however theexpiresAt
property is not updated even after a newaws sso login
call.If I wait more time and run aws sso login again it finally updates the
expiresAt
property.It seems that this is a likely reason for the issue I'm having. It seems like there is some mismatch with different expirations.
CLI version used
aws-cli/2.8.2 Python/3.10.7 Darwin/21.6.0 source/arm64 prompt/off
Environment details (OS name and version, etc.)
MacOS
The text was updated successfully, but these errors were encountered: