Skip to content

feat: support WebSocket authentication handling - #48512

Merged
codebytere merged 3 commits into
mainfrom
socket-fix
Nov 10, 2025
Merged

codebytere merged 3 commits into
mainfrom
socket-fix

Conversation

@codebytere

@codebytere codebytere commented Oct 10, 2025 •

Copy link
Copy Markdown
Member

Description of Change

Refs #48505.

This PR adds handling for the 'login' event to allow authentication via web sockets.

Checklist

Release Notes

Notes: Added support for WebSocket authentication through the login event on webContents.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Oct 10, 2025
@codebytere codebytere changed the title fix: webRequest.onAuthRequired() socket handling fix: webRequest.onAuthRequired() authentication handling Oct 10, 2025
@codebytere codebytere changed the title fix: webRequest.onAuthRequired() authentication handling feat: webRequest.onAuthRequired() authentication handling Oct 10, 2025
@codebytere codebytere added semver/minor backwards-compatible functionality target/39-x-y PR should also be added to the "39-x-y" branch. labels Oct 10, 2025
@codebytere
codebytere requested a review from deepak1556 October 10, 2025 10:33
@codebytere
codebytere marked this pull request as ready for review October 10, 2025 10:34
@nikwen

nikwen commented Oct 15, 2025

Copy link
Copy Markdown
Member

The PR has a merge conflict.

@codebytere
codebytere requested a review from a team October 15, 2025 09:10
Comment thread docs/api/web-request.md Resolved
@codebytere
codebytere force-pushed the socket-fix branch 2 times, most recently from 751d167 to c8f3f3f Compare October 15, 2025 10:22
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Oct 17, 2025

@jkleinsc jkleinsc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High level question, the current webRequest.onAuthRequired is specific to handling auth for websockets. Have we considered wiring it into our existing auth logic via the LoginHandler which emits app#login or webContents#login (depending on the session) instead of another entry point to handle authentication ?

@github-actions github-actions Bot added the target/40-x-y PR should also be added to the "40-x-y" branch. label Oct 28, 2025

@erickzhao erickzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@itsananderson itsananderson left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a full featured/consistent set of webRequest APIs seems useful, even if there's some overlap with the existing login events.

Comment thread docs/api/web-request.md Resolved

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a full featured/consistent set of webRequest APIs seems useful, even if there's some overlap with the existing login events.

We are creating a special handling for websockets authentication. I would rather align with our existing login handling which already manages multiple session types.

If we want the webrequest api as a consistent interface then it should also handle auth for other connection types as well, then in that case we should also decide a priority in auth handling callbacks given a user could setup multiple of them

app.on('login')
session.webrequest.onAuthRequired

@codebytere
codebytere force-pushed the socket-fix branch 3 times, most recently from 1072da1 to 96fc2cf Compare November 4, 2025 17:28
@codebytere

Copy link
Copy Markdown
Member Author

@electron/wg-api I refactored this per discussion with @deepak1556 - after some though I think his point that we should run WebSocket auth through the existing login event so we only have one auth path instead of two competing ones is compelling. Adding webRequest.onAuthRequired back for just sockets would create confusion and weird edge cases if folks wired both. Keeping everything on LoginHandler is simpler, predictable, and matches how other request types already work.

@codebytere
codebytere merged commit 4951b96 into main Nov 10, 2025
@codebytere
codebytere deleted the socket-fix branch November 10, 2025 20:30
@release-clerk

release-clerk Bot commented Nov 10, 2025

Copy link
Copy Markdown

Release Notes Persisted

Added support for WebSocket authentication through the login event on webContents.

@trop

trop Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "40-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot removed the target/40-x-y PR should also be added to the "40-x-y" branch. label Nov 10, 2025
@trop

trop Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "39-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/40-x-y needs-manual-bp/39-x-y and removed target/39-x-y PR should also be added to the "39-x-y" branch. labels Nov 10, 2025
nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* feat: support WebSocket authentication handling

* test: add a test

* refactor: route through login instead
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* feat: support WebSocket authentication handling

* test: add a test

* refactor: route through login instead
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
* feat: support WebSocket authentication handling

* test: add a test

* refactor: route through login instead
@trop

trop Bot commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

@codebytere has manually backported this PR to "40-x-y", please check out #49064

@trop

trop Bot commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

@codebytere has manually backported this PR to "39-x-y", please check out #49065

@Jason-123-cyber Jason-123-cyber left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review/approved ✅ merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants