Auth.signOut() doesn't redirect to the Cognito Hosted UI logout endpoint
See original GitHub issueThis is an OAuth scenario with the Cognito hosted UI
See sample code below. When clicking the signOut button I see that cookies get cleared, but the browser is not redirected to the /logout endpoint which I think it should be doing. Because it doesn’t do that, the user remains logged in at Cognito.
import React, { useState, useEffect } from 'react';
import Amplify, { Auth, Hub } from 'aws-amplify';
Amplify.configure({
Auth: {
region: 'us-east-1',
userPoolId: 'xxx',
userPoolWebClientId: 'xxx',
cookieStorage: {
domain: 'xxx',
},
oauth: {
domain: 'xxx.us-east-1.amazoncognito.com',
scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'],
redirectSignIn: 'xxx/parseauth',
redirectSignOut: 'xxx/',
responseType: 'code',
},
}
});
function App() {
const [user, setUser] = useState(null);
useEffect(() => {
const subscribeToHub = async () => {
Hub.listen("auth", ({ payload: { event, data } }) => {
switch (event) {
case "signIn":
setUser(data);
break;
case "signOut":
setUser(null);
break;
default:
break;
}
});
};
subscribeToHub();
}, []);
useEffect(() => {
Auth.currentAuthenticatedUser()
.then(setUser)
.catch(console.error);
}, []);
return (
<div>
<header>
{user && <p>Hi {user.username}!!</p>}
{!user && <p>You are not signed in</p>}
<button onClick={() => Auth.federatedSignIn()}>Open Hosted UI</button>
<button onClick={() => Auth.signOut()}>Sign Out</button>
</header>
</div>
);
}
export default App;
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Logout endpoint - Amazon Cognito - AWS Documentation
The /logout endpoint signs the user out and redirects either to an authorized sign-out URL for your app client, or to the /login...
Read more >Cognito logout does not work as documented - Stack Overflow
This redirect happens whenever logout_uri parameter doesn't match exactly what's listed among Sign out URL(s) in AWS Cognito User Pools App ...
Read more >cognito hosted ui logout failing with - AWS re:Post
Your call to the Cognito /logout endpoint shouldn't be an XHR request -- the browser needs to be redirected to there. Cognito will...
Read more >Logout - Auth0
Learn how to redirect users after logout. You can log a user out of the Auth0 session and (optionally) from the identity provider ......
Read more >Cognito Authentication for your SvelteKit app - Roberto Huertas
The Sign Out url is the final url to be redirected to once we've signed out from Cognito. Finally, for the Cognito Hosted...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kennethesguerra Didn’t find a solution. I’m thinking about integrating with Cognito directly, but haven’t investigated whether this will help yet… If anyone finds a solution that works with Amplify, please let me know, as I would much rather stick with it!
@charleswduk same situation also. Have you already found the workaround on this? This has been an issue a year ago though in amplify https://github.com/aws-amplify/amplify-js/issues/3435