fix(SUPPORT-19): address GoogleDrivePicker code review issues#965
fix(SUPPORT-19): address GoogleDrivePicker code review issues#965maxtechera wants to merge 1 commit into
Conversation
…GoogleDrive loader - Validate event.origin against window.location.origin in handleMessage (critical) - Add popup close detection via setInterval to clean up message listener (critical) - Remove remaining googleAccessToken fallback from GoogleDrive.ts init() - Add isReauthenticating loading state to re-authenticate button - Reset isReauthRequired in credential data effects when fresh token detected
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Review: fix(SUPPORT-19): address GoogleDrivePicker code review issuesSummary: This is a focused follow-up to #963 that addresses five security, correctness, and UX issues in the Google Drive OAuth2 re-authentication flow. The diff touches two files: Critical IssuesNo new critical issues found. The two critical items listed in the PR description are correctly addressed:
Major Issues1. Location: The
The real risk here: const cleanup = () => {
if (messageListener) {
window.removeEventListener('message', messageListener)
messageListener = null // prevent double-remove
}
if (closedPoller) {
clearInterval(closedPoller)
closedPoller = null // prevent double-fire
}
setIsReauthenticating(false)
}This is a minor correctness concern rather than a user-facing bug in practice, but worth hardening. 2. Unmounted component state update if auth popup completes after the picker unmounts Location: The Consider tracking the listener/poller in const messageListenerRef = useRef(null)
const closedPollerRef = useRef(null)
useEffect(() => {
return () => {
if (messageListenerRef.current) window.removeEventListener('message', messageListenerRef.current)
if (closedPollerRef.current) clearInterval(closedPollerRef.current)
}
}, [])Minor Issues and Suggestions3. Location: const accessToken = getCredentialParam('access_token', credentialData, nodeData)The removal of // access_token is the v2 field set by refreshOAuth2Token; googleAccessToken (v1) is no longer supported
const accessToken = getCredentialParam('access_token', credentialData, nodeData)4. Location: The existing 5. Polling interval of 500ms is reasonable but undocumented Location: closedPoller = setInterval(() => {
if (authWindow.closed) cleanup()
}, 500)500ms is a standard choice and works well. A brief comment explaining the intent (detect user-dismissed popup) would improve readability for future maintainers — similar to what the PR description already says, just inline. Positive Observations
TheAnswer-Specific Checklist
Next Steps
Overall this is a well-executed, focused fix. The security issue (origin validation) and the resource-leak fix (popup close detection) are both implemented correctly. The main hardening opportunities are around making Reviewed by Claude Code (claude-sonnet-4-6) |
Summary
Follow-up to #963 addressing all code review issues:
event.originagainstwindow.location.origininhandleMessageto prevent cross-origin message spoofingsetIntervalpopup close detection to clean up themessageevent listener when user dismisses the OAuth popup without completing auth|| credentialData.googleAccessTokenv1 fallback fromGoogleDrive.ts init()(was missed in previous migration commit)isReauthenticatingloading state — button shows "Opening Google sign-in..." while popup is openisReauthRequiredin both credential datauseEffecthandlers when a fresh (non-expired) token is detectedTest plan
/oauth2-credential/refresh/:idand reloads credentialisReauthRequiredclears, picker becomes available