fix(auth): fall back to sessionStorage for session token (fixes getSessionToken() returning undefined on BBB 3.0.30+)#269
Open
BrentBaccala wants to merge 1 commit into
Conversation
BBB 3.0.30 (bigbluebutton/bigbluebutton#25219, 'Hide sessionToken from URL bar') removes sessionToken from window.location at client startup and stores it in sessionStorage['BBB_sessionToken']. getSessionToken() read only the URL, so it returned undefined on 3.0.30+, breaking any plugin that uses it to authenticate (e.g. ?sessionToken=undefined rejected by the backend). Read the URL first (older cores and the brief pre-strip window), then fall back to sessionStorage. Version-agnostic; no behavior change on <3.0.30. Fixes bigbluebutton#268 Co-Authored-By: Claude <noreply@anthropic.com>
|
Thank you for this contribution! Could you please confirm if you already sent in the signed Contributor License Agreement? See https://docs.bigbluebutton.org/support/faq.html#why-do-i-need-to-sign-a-contributor-license-agreement-to-contribute-source-code Thanks in advance! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getSessionToken()returnsundefinedon BigBlueButton 3.0.30+, breaking any plugin that uses it to authenticate a connection.BBB 3.0.30 (bigbluebutton/bigbluebutton#25219, "Hide sessionToken from URL bar") removes
sessionTokenfromwindow.locationduring client bootstrap (history.replaceState) and stores it inwindow.sessionStorageunderBBB_sessionToken. Plugins mount after that bootstrap, so the existing getter — which reads only the URL query string — finds nothing and returnsundefined. The token is gone from the URL by the time any plugin runs.That PR notes no plugin/SDK impact; the SDK's reliance on the URL wasn't considered. The getter is unchanged across all releases, so this affects every SDK version on a 3.0.30+ core, and bumping the SDK does not help.
See #268 for the full write-up.
Fix
Read the token from the URL first (older cores, and the brief window before the strip), then fall back to
sessionStorage['BBB_sessionToken']— exactly where the 3.0.30 client now stores it. Version-agnostic, with no behavior change on cores< 3.0.30. ThesessionStorageaccess is wrapped intry/catchfor environments where it isn't available.Testing
Verified against the real-world failure that surfaced this: a remote-desktop plugin building
wss://host/vnc?sessionToken=${getSessionToken()}.GET /vnc?sessionToken=undefined→401; with this change, the token resolves fromsessionStorageand the connection authenticates (101).Note on
v0.1.xThe same getter exists on the
v0.1.xbranch (BBB 3.1.x), where 3.0.30's URL change is also present, so it's affected too. Happy to open a matching PR there if you'd like — this PR targetsv0.0.xsince that's the 3.0.x line where the regression was observed.This PR was prepared by an AI assistant (Claude) on behalf of Brent Baccala (cosine@freesoft.org), based on diagnosing a production remote-desktop plugin failure on BBB 3.0.30 and verifying the fix on live 3.0.30 and 3.0.29 servers.