-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Use POST for SAML login #52658
base: main
Are you sure you want to change the base?
Use POST for SAML login #52658
Conversation
Appears to be failing on an unrelated tyepscript check error - but should be ready for review
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly have some questions / clarifications :)
src/libs/LoginUtils.ts
Outdated
} | ||
return response.json() as Promise<Response>; | ||
}) | ||
.then((response) => response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this second .then()
? Can we return the json in the previous .then()
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, at least from my testing we need both - I also followed the convention from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the convention in this case? I don't see .then((response) => response);
in the linked code, and was also wondering about this because this line looks like no-op
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this is actually fine without - removing!
return fetch(CONFIG.EXPENSIFY.SAML_URL, { | ||
method: CONST.NETWORK.METHOD.POST, | ||
body, | ||
credentials: 'omit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious - why are we setting credentials:omit
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the convention used here - I can test without it but figured it was safest to go with logic we already knew worked.
} | ||
|
||
const body = new FormData(); | ||
body.append('email', credentials?.login ?? ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if email is set as an empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think rn the iDP page fails to load so they get stuck on the loading screen, i'll update the logic to return early if there's no login to pass.
Navigation.navigate(ROUTES.HOME); | ||
|
||
Navigation.isNavigationReady().then(() => { | ||
// We must call goBack() to remove the /transition route from history |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious - where is this transition route set? Is it only from OldDot -> NewDot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah OldDot -> NewDot - here
Co-authored-by: Maria D'Costa <[email protected]>
…ikki-saml-use-post
updated once more 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Can you ask a C+ to complete the reviewer checklist with tests in all platform 🙏 ?
There are a bunch of test steps here. Which test suites do I have to follow @NikkiWines? |
@parasharrajat just the steps under |
In the process of adding a verified domain to my test account. |
import SAMLLoadingIndicator from '@components/SAMLLoadingIndicator'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import {handleSAMLLoginError, postSAMLLogin} from '@libs/LoginUtils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to import this as import * as LoginUtils
format.
renderLoading={() => <SAMLLoadingIndicator />} | ||
onNavigationStateChange={handleNavigationStateChange} | ||
/> | ||
{!!SAMLUrl && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we show the loader until we have the url?
const [showNavigation, shouldShowNavigation] = useState(true); | ||
const [SAMLUrl, setSAMLUrl] = useState(''); | ||
const webViewRef = useRef<WebView>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get the use of this ref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about it either but I saw the same usage for multiple other WebViews (see: ConnectToQuickbookOnlineFlow, ConnectToXeroFlow, WalletStatementModal) and figured it was wise to follow that existing convention
@parasharrajat sorry for the delay, I was OOO for the EOY holidays. Just to confirm, have you done the following:
The error you're seeing appears to be due to your email not passing some validation checks. If you want to share the email you're using and try again I can pull the logs for your account and see if I can help figure out what's going wrong. |
I am using the admin account to login which has the domain. Email is contact@netvade[DOT]com |
From the internal logs it looks like the issue is that the cc: @cead22 you might know a bit about this as it looks like it was modified fairly recently in your PR here
|
Let me analyze this. |
I believe I am doing something wrong. I used Auth0 to setup SAML but I created the account from my gmail email. |
Hmm, yeah - you'll definitely need parity between the email used for the account and the email used for Auth0/SAML |
@parasharrajat you might try OneLogin's 30 day free trial to test this |
Setting up OneLogin and I will have this test in 8 hours due to traveling. |
Ok, I was able to login and I am redirected to OldDot afterwards. @NikkiWines 10.01.2025_18.03.31_REC.mp4 |
Ah, yes, this is because when doing the SAML routing via dev we don't persist some of the cookies that we use to determine whether to route the user to New Expensify vs. Expensify Classic. I experience the same thing locally unless I hardcode those values for testing purposes. I can confirm that your account is going through the
cc:: @cead22 what do you think? |
Let me test this on all platforms in that case. |
Screenshots🔲 iOS / native11.01.2025_02.54.01_REC.mp4🔲 iOS / SafariCORS error 🔲 MacOS / Desktop11.01.2025_02.42.10_REC.mp4🔲 MacOS / Chrome401987740-33c990b7-972c-4a13-a465-fa60d7f928ec.mp4🔲 Android / ChromeCORS error 🔲 Android / native11.01.2025_02.52.02_REC.mp4 |
@NikkiWines I noticed that even on native dev apps the redirection does not happen to app, after login, user is redirected to oldDot website in the opened webview instead of going back to app. Is this expected? |
Explanation of Change
Updates the SAML login flow to use a POST request instead of opening a user-modifiable URL
Dependant on https://github.com/Expensify/Web-Expensify/pull/44462
Fixed Issues
$ Tied to https://github.com/Expensify/Expensify/issues/424196
PROPOSAL: N/A
Tests
(Internal)
Success Flow
Use Single Sign On
optionError Flow
try{
here:throw new ExpException('An error occurred while loggin in, please try again.', 403);
Use Single Sign On
optionAn error occurred while loggin in, please try again.
Notes for dev testing:
For the newDot redirect to work locally you may need to hardcode the following value to
true
.For mobile testing, you will need to change the url in OneLogin's Expensidev application to your ngrok url instead of
https:://www.expensify.com.dev/
so that it loads correctly on the simulators. You can do that by loggin into OneLogin (using carlos@ or dbondy@ creds in 1Pass), going to Administration > Left Hamburger Menu > Applications > Applications > Expensidev Connection > Configuration and updating the urls inACS (Consumer) URL Validator
andACS (Consumer) URL
Lastly, for Android mWeb, if you use
127.0.0.1:8082/
for your newDot URL, you'll need to update the usage ofURL_TO_NEWDOT
here to use that URL instead.(External)
Use Single Sign On
optionOffline tests
N/A SAML is not supported offline
QA Steps
Log into New Expensify with the email [email protected]
Choose
Use Single Sign On
optionConfirm you briefly see an interstitial page about launching your SSO provider's login portal
Enter the SSO credentials for [email protected] (in 1password under
QA OneLogin
)Confirm you're redirected back to New Expensify and are logged into your account
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Error:
Screen.Recording.2024-11-28.at.18.19.42.mov
Success:
android.success.mov
Android: mWeb Chrome
Error:
mweb.android.failure.mov
Success:
android.mweb.success.mov
iOS: Native
Error:
ios.error.mp4
Success:
ios.success.mp4
iOS: mWeb Safari
Error:
ios.mweb.error.mp4
Success:
ios.mweb.success.mp4
MacOS: Chrome / Safari
Error:
web.error.mov
Success:
web.success.mov
MacOS: Desktop
Error:
desktop.error.mov
Success:
desktop.success.mov