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

vuexOidcProcessSilentSignInCallback issue again #125

Open
apavelm opened this issue Sep 3, 2020 · 13 comments
Open

vuexOidcProcessSilentSignInCallback issue again #125

apavelm opened this issue Sep 3, 2020 · 13 comments

Comments

@apavelm
Copy link

apavelm commented Sep 3, 2020

Today I gave a try to updated version (3.9.5) and faced with a strange behavior. I'm not sure that it is related to "vuex-oidc" or this is a bug of "oidc-client-js".

Given: I have an application where for testing purposes I added 2 ways of token renewal:

  1. Classic by using automaticSilentRenew: true in oidc config
  2. Manual, by clicking a button
    image

Here is a script on "Silent" page (silent_redirect_url):
image
So, I expect to see "then" in console when token renewed and "failed" otherwise.

In normal mode (no exceptions) both work fine.

But when session cookies are invalid (so we expect "catch" routing to be triggered)

  1. It continues to report "then" like token updated
  2. for manual approach (2) it works different, like in a chain of calls in (1) with added additional one and now we can add a fallback call.
    image
    image

Of course (2) is not applicable for automatic routing, but in the same time processSilentSignInCallback is just a
image

I'm confused. Any ideas why I'm still getting "OK" instead of "ERROR"?

Probably here could be a workaround, something like a watcher on oidcError, but it will not look good.
Or I'm doing something wrong? Please advise.

@perarnborg
Copy link
Owner

OK, thanks for reporting! I will look at this as soon as I find the time!

@apavelm
Copy link
Author

apavelm commented Sep 3, 2020

@perarnborg Thank you for response and promise to have a look :-)

Just have checked a code little deeper.
Probably a quick fix will be to replace
this (highlighted)
image

by this (highlighted)

image

@perarnborg What do you think?

@perarnborg
Copy link
Owner

@apavelm The change you suggest is actually already suggested in #123 – but I do not think that this is the cause of your problem.

The callback method UserManager.signinSilentCallback of oidc-client will never throw an error – not for the automatic silent renewal or one that is manually triggered. The error when silent signin fails can only be caught in UserManager.signinSilent – like you do with the catch on the authenticateOidcSilent action in your test of manually triggering silent renewal.

I see that it would be useful to be able to catch when automatic renewal is failing, but it is not possible to do this on the callback page. I am thinking of adding an event that you can listen to for this, I'll try to look into that shortly.

@perarnborg
Copy link
Owner

@apavelm As of v3.9.7 there is a automaticSilentRenewError event that you can add a listener for to catch when automatic silent renew fails.

See events in docs

@apavelm
Copy link
Author

apavelm commented Sep 7, 2020

@perarnborg Thank you for the fast modification.

Unfortunately, it doesn't work, at least for me.
Maybe I'm doing something wrong, but I'm not sure. It's hard to add a listener wrong way

  1. I updated library to 3.9.7
  2. added listeners
    image
  3. removed session cookies and updated the page to trigger auto-silent-renew
    image

But there is no new log messages there
image

silent-renew.js:
image

UPDATED
But it works if I trigger "authenticateOidcSilent" manually, where I could use "catch" to catch an exception previously. From this point of view nothing changed. I'll review PR a later, maybe there is something more to modify in respect to this event.

@perarnborg
Copy link
Owner

OK, looks correct to me so I will need to look at this again to see why id doesn't work. Let me know if you find anything!

@perarnborg
Copy link
Owner

@apavelm Can you check what version of oidc-client you have installed?

@apavelm
Copy link
Author

apavelm commented Sep 11, 2020

@perarnborg
"oidc-client": "^1.10.1"

I did a workaround, by disabling "automatic silent renew" and listening OnTokenExpiring/OnTokenExpired to call silent renew manually (to be able to use "catch")

@perarnborg
Copy link
Owner

I cannot reproduce this, strange that the event does not seam to be dispatched for you. I did a small alteration in v3.9.8, it might work better with that if you want to try.

Anyway, if you are doing the manual renewal by dispatching the authenticateOidcSilent your work around should work well.

@apavelm
Copy link
Author

apavelm commented Sep 14, 2020

I did a workaround on this by disabling "auto-renew" feature + subscribing to OnTokenExpiring event to renew the token manually (because only on manual renewal I am able to catch exceptions)

Thanks, anyway. Hope it will be useful for others.

@hawkstalion
Copy link

hawkstalion commented Oct 1, 2020

Can you tell me how you renewed the token manually? By calling a function in this library or doing the refresh request manually? I am having this issue but it works the first time and then when you refresh the page it stops working. No errors in the error events and the accessTokenExpiring/Expired still fire. I tried to use dispatch to fire 'authenticateOidcSilent' but i had to register the oidc module to the store dynamically and it couldnt find the 'authenticateOidcSilent' action and then it had a lot of issues where it couldnt find the module even though it was registered.

@apavelm
Copy link
Author

apavelm commented Oct 1, 2020

I disable an auto-renewal and listening for tokenExpiring event. When it triggers, I manually call a renewal. When I do it manually I can catch exceptions.

@hawkstalion
Copy link

We figured out the issue with ours, the vuex-persist library was interfering, i excluded the vuex-oidc module from it and it worked perfectly.

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

No branches or pull requests

3 participants