Open simha453 opened 8 months ago
Hi @simha453 thank you for opening this issue. I'd like to clarify what you are experiencing - is this happening when:
Auth.signOut()
Auth.federatedSignIn({ provider: 'AzureAD' })
Did i understand correctly?
The scenario is, When the user tries to login first time, it works perfectly fine. But, when the user closes the tab or logout, and tries to login again by opening the new tab, user get this error page. Again the user has to close the tab and have to login again
Hi @simha453 thank you for opening this issue. I'd like to clarify what you are experiencing - is this happening when:
- User signs out through -
Auth.signOut()
- User tries to sign back in through -
Auth.federatedSignIn({ provider: 'AzureAD' })
- They see the screenshot you shared above
Did i understand correctly? The scenario is, When the user tries to login first time, it works perfectly fine. But, when the user closes the tab or logout, and tries to login again by opening the new tab, user get this error page. Again the user has to close the tab and have to login again
@simha453 thanks for the clarification - it looks like the issue is on the Azure side where it looks like its processing a sign out rather than a sign in. Are you able to reproduce this without using Amplify? Specifically if you go to Cognito Hosted UI and try to login from there instead.
We tried Cognito Hosted UI it's logging in perfectly. Sign-out page is not coming
Any update on this ticket?.
Looking for your reply, any update on this ticket
Hi @simha453 after looking at this a bit more, Im a bit curious on how you are using the function you have defined as onSetOTPAwsConfig()
. From looking at it, it looks like it handling the identity pool credentials which may be causing a conflict with what Amplify does for you under the hood.
Can you clarify what it does, and possibly remove it and see if you still experience this issue/
Here i am mentioning complete code and use of onSetOTPAwsConfig() , and i have removed and tested getting same error.
const [isError, setIsError] = useState(null)
const [view, setView] = useState(EMAIL_FORM_VIEW.EMAIL_VIEW)
const { mutate, isLoading } = useLoadOrganizationList()
const { dispatch } = useAuthContext()
const awsConfig = {
Auth: {
identityPoolId: `${process.env.REACT_APP_AD_IDENTITY_POOL_ID}`,
region: `${process.env.REACT_APP_AWS_REGION}`,
userPoolId: `${process.env.REACT_APP_AD_USER_POOL_ID}`,
userPoolWebClientId: `${process.env.REACT_APP_AZURE_AD_WEB_NO_SECRETE_CLIENT_ID}`,
oauth: {
domain: `${process.env.REACT_APP_AD_DOMAIN_NAME}`,
scope: ['email', 'openid'],
redirectSignIn: isLocalhost()
? 'http://localhost:3000/login'
: process.env.REACT_APP_REDIRECT_SIGNIN_URL,
redirectSignOut: isLocalhost()
? 'http://localhost:3000/login'
: process.env.REACT_APP_REDIRECT_SIGNOUT_URL,
responseType: `${process.env.REACT_APP_AD_RESPONSE_TYPE}`,
label: 'Log in with your company SSO',
clientId: `${process.env.REACT_APP_AZURE_AD_WEB_NO_SECRETE_CLIENT_ID}`,
},
},
Analytics: {
disabled: true,
},
}
Amplify.configure({ ...awsConfig, ssr: true })
const onSetOTPAwsConfig = async ({ idToken }) => {
// Set the region where your identity pool exists (us-east-1, eu-west-1)
AWS.config.region = process.env.REACT_APP_AWS_REGION
// Configure the credentials provider to use your identity pool
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: process.env.REACT_APP_AD_IDENTITY_POOL_ID,
Logins: {
[`cognito-idp.ap-south-1.amazonaws.com/${process.env.REACT_APP_AD_USER_POOL_ID}`]:
idToken.jwtToken,
},
})
}
const getUser = async () => {
const { signInUserSession } = await Auth.currentAuthenticatedUser()
console.log({ signInUserSession })
if (signInUserSession?.idToken?.payload?.email) {
sessionStorage.setItem(AUTH_SESSION_CHECK, true)
sessionStorage.setItem(
AUTH_SESSION_DATA,
JSON.stringify(signInUserSession)
)
dispatch({
type: loginConst.LOGIN,
payload: signInUserSession,
})
setIsError(null)
onValidationSuccess()
} else {
setIsError('Login Error')
}
}
useEffect(() => {
Hub.listen('auth', async ({ payload: { event, data } }) => {
switch (event) {
case 'signIn':
case 'cognitoHostedUI':
await onSetOTPAwsConfig(data.signInUserSession)
await getUser()
break
case 'signOut':
await Auth.signOut()
break
case 'signIn_failure':
case 'cognitoHostedUI_failure':
console.log('Sign in failure', data)
break
default:
break
}
})
}, [])
@nadetastic It is really a pain that AWS Amplify does not support Azure AD out of the box and we have to do workarounds. We are also implementing our company SSO and with v6 there has been a lot of change in APIs but no proper documentation.
BTW, Do we know how to avoid hosted UI? Also if I have only one login option i.e. via Azure AD, Can I skip hosted UI and directly redirect to MS login?
Resolved for me with #13119
Any update on this ticket?
Any update on this?
@simha453 I'm not sure what you're trying to do with the sessionStorage
part of your code, but that getUser()
function may be messing with how Amplify is handling things out of the box. Similar to how you tried commenting out onSetOTPAwsConfig
, can you see if commenting out/removing the getUser
section (and where it's referenced in the Hub events) change the behavior at all?
And out of curiosity, have you considered upgrading to a more recent version of Amplify? v5 would require less work than the newest v6, but both would offer some improvements and fixes!
@simha453, wanted to ping again and see if you had a chance to review the above comment.
I have commented the getUser section and upgrading to latest versions v5, v6. I have tried the both cases . but not working getting same error. Give me any proper solution for this bug.
any update ?
any update ?
any update? or is there any config that can we set on AD side?
Any update ?
We have been waiting for a long time for your update. Give me update on this ASAP
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Version
Older than v5
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
Upon attempting to "login using Outlook" in Cognito, users encounter an unexpected logout screen instead of being redirected to the login page of Outlook. This issue arises specifically after logging out from the application, not from the Outlook platform itself.
Expected behavior
It should go to login page of outlook azureAD
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
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