-
Notifications
You must be signed in to change notification settings - Fork 549
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
Manually expire or invalidate tokens and get new issued. #696
Comments
Hi @grohj , We don't currently support re-fetching the id token when it is not expired.
I will check with the service team to see if there are any other flows available for you to use. |
Hi @grohj , You will need to force refresh the tokens using the method in my previous post. We will investigate adding exposing this functionality in our clients. |
Hi @minbi , I really appreciate your response. I used basically the first option you provided. The second one is hacky approach which I won't take my chances with. Anyways, glad you are considering to add this feature, looking forward to see it :) Thanks. |
Hello, Thanks |
Hi @minbi, Any update on this as it is a valid use case when using custom claims? |
@sachinavm12 At this point we do not have an update on this feature. I have added this to the #634 for tracking. We will post an update once the feature is released. |
Hi, @desokroshan Can you provide any new info about when this feature is going to be done? Btw it seems that this feature is already done in iOS SDK and presented as |
Hi, |
Is this anything you'd consider accepting a pull request for? It's been blocking our development for quite a while, especially painful considering it's already present on iOS. |
As reference, I'm tracking our closed ticket #2637 here as well. It's unfortunate that this is not prioritized and we can't have feature parity with the iOS SDK. |
agree that this is unfortunate as it would be great to have a solution to this. |
Note there's a (very fragile) workaround over on this related ticket, to do this by accessing a private field and 3 private functions. Would be so good, so appreciated, if that was exposed properly, stable, supported, etc. However for us poor saps trying to make this work in the meantime, that may be the only option for now 🤷 |
This is a very important feature to our app, currently if the user is added to a new Cognito group while logged in we have to ask the user to log out and back in to retrieve the new group setting. |
Hello all , here is a test that uses Line 484 in 0681a5c
As a reference, this is the revokeTokens implementation. Please let us know if this function would work for you or you would like a function with different behaviors. Thanks! Line 2340 in 0681a5c
|
Hi @frimfram, This doesn't work for my use case, for me it is an attempt to support dynamic auth groups within DataStore. My issue is that when a user is added to a new Cognito group their current token isn't updated with the new group, this is understandable, so to retrieve the new group I would like the login token to be revoked and a new one issued without the user needing to sign in again. |
Revoking tokens and issuing new one automatically in one function can lead to big security hole so we'll need to evaluate implication thoroughly. Here are some discussions on a related problem: aws-amplify/amplify-js#1213 (comment) In the meantime, something like using "revokeTokens" to clean up the user session and calling "signIn" function and/or re-issuing your "IdToken" may work and lead to more secure result. |
The main issue for my use case is simply that a users current token doesn't reflect their real time cognito groups and signing out and back in or revoking and issuing a token is just a work around for that issue to give the user their real permissions. It sounds like for me, and the others in this thread, we just need a way to update the information stored with the current token so that it matches any changes made to the back end data |
@frimfram Thanks but the request here is specifically to avoid signing the user out and the poor UX that leads to. As for security concerns, the thing being asked for is parity with a feature the iOS SDK already offers, so worth checking that out regarding those. Obviously caution is justified but perhaps their implementation could inform this one. |
@jonreeve sorry that it was not clear. Line 2702 in 0681a5c
iOS does not support clearing and auto generation of session in one function (proactive refresh): |
@frimfram in the issue you linked to, there's this comment that describes using This is the implementation of this function on iOS for reference: https://github.com/aws-amplify/aws-sdk-ios/blob/main/AWSCognitoIdentityProvider/AWSCognitoIdentityUser.m#L1465-L1473 The
What does currently work for us, for comparison, is this approach that currently requires reflection to access. What we're looking for is a function on the Android SDK to clear id + access token but NOT refresh token, so that the tokens (and thus the user attributes that have changed) will be refreshed upon next use, exactly as currently happens on the iOS SDK. |
Hello Everyone. Is there any update on this subject? For the momento I'm applying the solution @minbi propose, with the clear manually of the idToken and accessToken from sharedPreferences and then forcing a refresh. But I don't know how dangerous is this. |
Please use the following as a workaround until we find a proper solution: Set the refresh threshold higher than current expiration of idToken or accessToken to force a refresh. During the subsequent getTokens calls, the library will fetch new tokens as long as refreshToken is not expired.
new Thread(() -> {
try {
CognitoIdentityProviderClientConfig.setRefreshThreshold(100000);
AWSMobileClient.getInstance().getTokens();
} catch (Exception e) {
e.printStackTrace();
}
}).start(); |
If the workaround does not work, please comment on this issue or open a new one. |
This workaround doesn't work. This threshold is not big enough to trigger for new AccessToken. Also, I can't set more than 1800000.
Is there anything I'm missing @div5yesh ?
|
State your question
We are using IdToken to identify user in our backend. The IdToken contains information like users name, etc. If user decides to change his personal information, this changes doesn't propagate into existing IdToken. Data is present in the token upon its refresh.
Is there a way to invalidate existing tokens, and force the pool to issue new one?
Btw logging out and loggin in again is out of question, because we are using passwordless login procedure.
Which AWS Services are you utilizing?
Cognito
Environment(please complete the following information):
The text was updated successfully, but these errors were encountered: