-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Getting signed out while trying to sign in via Azure AD #12975
Comments
Hi @simha453 thank you for opening this issue. I'd like to clarify what you are experiencing - is this happening when:
Did i understand correctly? |
The scenario is, |
|
@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 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 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 ? |
1 similar comment
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
The text was updated successfully, but these errors were encountered: