Closed israx closed 2 months ago
Based on the information provided, it appears that you're experiencing an issue with logging out from App2 in a single sign-on (SSO) setup using AWS Amplify v6 with Angular. The problem seems to be related to the logout process not being properly handled for App2. Here's a workaround to address this issue:
Update your logout function to explicitly specify the redirectSignOut URL for each app. This ensures that the correct redirect URL is used regardless of which app initiates the logout process.
Modify your logout function in both App1 and App2 to use the following code:
import { signOut } from 'aws-amplify/auth';
async function logout() {
try {
await signOut({
global: true,
oauth: {
redirectSignOut: 'https://app1.dev.mydomain.com/login', // Update this URL for each app
},
});
} catch (error) {
console.error('Error signing out: ', error);
}
}
Ensure that the redirectSignOut
URL matches the one specified in your Cognito User Pool App Client settings.
Update your AWS Amplify configuration in both apps to include all possible redirectSignOut URLs:
const awsAmplifyConfig: ResourcesConfig = {
Auth: {
Cognito: {
// ... other configurations
loginWith: {
oauth: {
// ... other oauth configurations
redirectSignOut: [
'https://app1.dev.mydomain.com/login',
'https://app2.dev.mydomain.com/login'
],
}
}
}
}
};
This workaround should resolve the issue by ensuring that the logout process is handled consistently across both applications. The global: true
option in the signOut
function will attempt to sign out from all devices, and specifying the redirectSignOut
URL explicitly in the logout function will override any issues with matching the current window URL.
If you continue to experience issues after implementing this workaround, please provide more detailed error logs or network request information during the logout process from App2.
I was able to solve the issue. Thanks
Thank you for raising this issue. If you have any questions or if this issue resurfaces, please don't hesitate to reopen it or create a new one.
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication, Storage
Amplify Version
v6
Amplify Categories
auth, storage
Backend
Other
Environment information
Describe the bug
I am using Angular version 17.3.12 and Amplify v6.4.2. Using hosted UI as login method. We are make use of the Single sign on since we have multiple angular applications. Also, using Cookie storage as the storage mechanism for the amplify library.
The scenario is, [Consider I have 2 applications named App1 & App2]
Expected behavior
While using Single sign on with my applications having same domain, expected to completely logout from all the linked applications seamlessly.
Reproduction steps
Code Snippet
Log output
aws-exports.js
Manual configuration
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response