amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

Ability to specify query parameters for logout URL when calling signOut()

Open Bohdan-Kalynovskyi opened this issue 2 years ago • 4 comments

Is this related to a new or existing framework?

React

Is this related to a new or existing API?

Authentication

Is this related to another service?

Cognito

Describe the feature you'd like to request

When the user gets logged out due to inactivity, it's particularly useful to save the page URL before redirecting him to logout page. This would allow him then to get back to where he left off when starting the new session.

Common practice to achieve this is to store the current URL as the query parameter and append that parameter to logout URL. For example, using auth0-js:

  1. const returnTo = 'https://example.com/logout?saved_url=' + encodeURIComponent(location.href)
  2. auth0.logout({ returnTo })
  3. // after user logs in again - use saved_url query param

Amplify-js .signOut() does not support an option similar to returnTo, so I request it here.

Describe the solution you'd like

Add an argument to signOut() method that would allow overriding logout URL (or redirectSignOut oath config in other words). Or at least allow appending query to logout URL

Describe alternatives you've considered

sessionStorage is an alternative that would work in some cases. The problem is that according to RFC-2109 sessionStorage should be cleared when closing the page, so this won't work if the browser restarts before the user logs in again

Additional context

No response

Is this something that you'd be interested in working on?

  • [ ] 👋 I may be able to implement this feature request
  • [ ] ⚠️ This feature might incur a breaking change

Bohdan-Kalynovskyi avatar Oct 13 '22 19:10 Bohdan-Kalynovskyi

Would be great to have this implemented. Is there a timeline on this?

jkelting avatar Dec 07 '22 19:12 jkelting

Would love to see this as well! According the AWS Cognito docs, the logout endpoint supports a state query param where this value could be passed in as so just exposing customState to Auth.signOut like you have for Auth.federatedSignIn

dwilt avatar Apr 06 '23 18:04 dwilt

this is one of the most needed feature, very basic one, not sure how this is missed out. right now if there is slight change sigonout url, if just fails. Ideally it should allow the query parameters to be appended to logout_uri value when it is sent as url encoded.

yadavvineet avatar Apr 21 '24 00:04 yadavvineet

Hi, we also need this feature. Is there a very rough prediction when it will be implemented? We are currently planning to implement a workaround, but maybe we just can wait.

Twonky-Chris avatar Apr 25 '24 10:04 Twonky-Chris