Skip to content

feat: Add broadcaster to OAuth

Paul Slaughter requested to merge ps-oauth-part-4-broadcasting into main

Description

This MR is the last part of !240 (closed) which introduces a Broadcaster that utilizes BroadcastChannel. This way other Web IDE tabs can be notified if the OAuth token is updated in a separate tab.

Screenshots

  1. Apply this patch which sets the tokenLifetime and applied the logging changes in !257. 0001-patch-Add-minLogLevel-to-config-and-set-token-time.patch.
  2. Open the example app and start with Authentication Type as OAuth (see relevant docs).
  3. Open mutliple tabs of the example app with the same config.
  4. Wait a few seconds for the token to expire (i.e. ...expiresAt - Date.now() to be under 300000) then open a file you haven't opened before. In the console log you should see OAuthClient - starting token refresh.... The other tabs should not have this log.
  5. Switch to another tab and try to open a file you haven't opened before. The file should open successfully and no OAuthClient - starting token refresh... logged since the other tabs received a signal to update their token cache.

20231119_demo

Edited by Paul Slaughter

Merge request reports