Skip to content
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

Refactor the service worker #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elken
Copy link

@elken elken commented Nov 24, 2023

Using workbox to allow us access to setting up a route to handle the token resposne for any call to an /oauth/token endpoint that we have a valid config for & to improve general stability of the worker.

Also uses IndexedDB to store the token data (I can also refactor the main index to use IndexedDB for consistency) rather than relying on a global variable in a service worker. Service workers in general have no guarantees about lifetimes, they can be killed for any reason and we were seeing this behaviour across multiple devices and environments where the authentication setup would just drop out and the user would have to re-auth.

IndexedDB scope is limited to the origin only, so with a sensible CSP on the frontend server there is no compromise in security as far as I'm aware here.

Tested all day yesterday periodically refreshing the petshop demo app & randomly removing the access token & expiry and I was always able to regenerate the token.

These changes also make some possibly aggressive assumptions about the behaviour of token refreshing, so happy to have a discussion about rolling some of them back 😄 There are docs changes I should add in here too, but I'm anticipating the aforementioned discussion, if this is going to be accepted then I'll also add in needed changes

Using workbox to allow us access to setting up a route to handle the
token resposne for any call to an /oauth/token endpoint that we have a
valid config for & to improve general stability of the worker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant