How to handle session termination in ServiceWorker

EDIT 1

One thing that I did not explain in my use case was that the browser does not need to show UX for authentication or, at least, optional.

var credential = await navigator.credentials.get({ password: true, mediation: "silent", federated: {providers: federatedProviderURL}} ); 

If a user has disabled or deleted passwords from UA, he will fail (credentials == null).

Credential specification authors may stipulate that when calling from ServiceWorker, mediation must be "silent" or, if not, there is no user interface: a <->

Error - NOUI action requires user interface to terminate

But the important point here is that in the vast majority of cases re-authentication without a key can be performed.

Does this change anything?

Greetings from Richard

ORIGINAL MAIL: -

If Fetch in my ServiceWorker receives 401 from the server, how do I re-authenticate with the server if I do not have a focused or redirected client?

NB: I'm talking about POST requests that update the server, and not just reading from the cache until the network returns.

Bring customer into focus? It is scary for the user without any actions causing this reaction, and, perhaps, they will not be able to log into the system again.

What does Background-Synch do if it gets 401?

If navigator.credentials surfaced in ServiceWorker, that would be enough!

Sessions that do not end?

What are other people doing?

Once again I am banned from the W3C / IETF Github: - (

If someone can add the following to ServiceWorker issues that will help: - See a Usage Example

If the user session has expired, ServiceWorker does not currently have mechanisms for re-authenticating with the server, since there is no heuristic mechanism for determining credentials.

If credentials.get () was available, re-authentication can be transparent. If the federation (say, Google), then if the user is logged out, this state will be executed.

+5
source share
1 answer

It seems to have been discussed before. Please sea github

I think that re-authentication of the background should be infrequent so that notification of entry or exit is a suitable and user-friendly solution.

Comment on this if you have any ideas!

+1
source

Source: https://habr.com/ru/post/1273416/


All Articles