-
Notifications
You must be signed in to change notification settings - Fork 188
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
chore(compass-web): refactor sandbox to better handle cert issuing logic #6295
Conversation
@@ -112,6 +129,23 @@ class AtlasCloudAuthenticator { | |||
return new URL(url, 'http://localhost').pathname.replace('/v2/', ''); | |||
} | |||
|
|||
async #fetch(path, init) { |
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 keep forgetting that private properties are even a thing for literally years at a time 😆
bw.close(); | ||
}); | ||
}), | ||
once(bw, 'close', { signal: abortController.signal }).then(() => { | ||
throw new Error('Window closed before finished signing in'); | ||
}), | ||
]); | ||
electronApp.dock.show(); | ||
electronApp.dock?.show(); |
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 know this is old code, but what's this doing? Is it this https://www.electronjs.org/docs/latest/api/dock#dockshow-macos ? That returns a promise, btw.
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.
On macos it hides the dock icon when we're doing showing a browser window for login purposes. Just makes it behave closer to a console process when there are no actual UI spawned by this process. I'll need to rewrite this file to typescript at some point... 🙈
await session.defaultSession.clearStorageData({ storages: ['cookies'] }); | ||
async cleanupAndLogout() { | ||
// When logging out, delete the test user too. If we don't do this now, we | ||
// will loose a chance to do it later due to missing auth |
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.
grammar nit: lose, not loose. loose is an adjective that means not firmly attached 😄
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.
Thanks! Fixed in both places where I made this mistake 😅
try { | ||
await atlasCloudAuthenticator.deleteTestDBUser(); | ||
} catch { | ||
// Can fail if user wasn't even created yet |
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.
nit: maybe worth at least debug logging when we ignore errors just to make sure that it is the error we expect and not some NPE or other programmer error. (I'm aware that this isn't exactly intended to be production code)
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.
No, yeah, good idea, doesn't hurt to log here 👍
@@ -282,6 +360,10 @@ proxyWebServer.use('/authenticate', async (req, res) => { | |||
|
|||
try { | |||
const { projectId } = await atlasCloudAuthenticator.authenticate(); | |||
// Start issuing the cert to save some time when signing in | |||
void atlasCloudAuthenticator.getX509Cert().catch(() => { | |||
// ignore errors |
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.
Similar comment to elsewhere. Should this at least debug log?
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.
Will add one to the get method itself, thanks 👍
Now that we actually using sandbox more for feature development, some pain points started to show up, this patch tries to address those:
electron.net
in theAtlasCloudAuthenticator
, using electron network stack should actually deal with two things: we don't need to manually get the cookie for those requests, electron can map them on it's own by domain name, but also it should take the cookie setting response into account correctly, meaning less chance for the token to expire