-
Notifications
You must be signed in to change notification settings - Fork 689
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
Consider supporting iframe silent refresh in Authorization Code + PKCE flow #600
Comments
Another reason to prefer the With refresh tokens you are working completely outside the user session, that's why it's called |
In this commit in my sample repo you can see some of the hoops I'd have to jump through in my production applications too. Would be really nice to have the |
Honestly, this is an implementation/ configuration detail. The current best practices document suggest to limit the usage of such a refresh-token for the time of the session. The only concern that stays -- also after respecting the current best practices document -- is that the refresh_token can be stolen via XSS. The iframe trick can help here b/c it allows to use http-only cookies. |
@jeroenheijmans I'll make this a priority. |
Recently released versions 8.x introduced support for "Code Flow" (Authorization Code + PKCE). While trying to upgrade my sample repositlory to utilize this flow I'm running into an issue.
It seems that silent refresh via an iframe is not supported with Code Flow in angular-oauth2-oidc?
Current situation
Even though you could ask for
offline_access
as suggested by the Code Flow docs for this library, and then utilizerefresh()
instead, I think the iframe method can be at least as useful, if not more. It allows you to initiate a silent refresh when starting your application (if you want this negates the need for localStorage too), and in general prevents having to ask for refresh tokens (which are often deemed too powerful for SPA's).I shortly wondered if "the iframe silent refresh trick" would even work with Code Flow, but found some evidence that it should do so:
So, I think our library could and should support it just fine.
The code
Here's the relevant
tryLogin
method:angular-oauth2-oidc/projects/lib/src/oauth-service.ts
Lines 1374 to 1381 in a1652dc
This method is called:
code
hash fragment parameter and others from thewindow.location
silent-refresh.html
pageAs you can see in the code above,
tryLoginCodeFlow
is called without arguments, that is the iframe's message is discarded in the second scenario.This makes sense, as the method does not support being called with a
customHashFragment
grabbed from the iframe's message:angular-oauth2-oidc/projects/lib/src/oauth-service.ts
Lines 1398 to 1401 in a1652dc
Proposed change
I propose we change
tryLoginCodeFlow
to support passing along something likeLoginOptions
. We most likely would need to tweak things, as with the code flow the response data is in the query string parameter, not the hash fragment (I think?).The text was updated successfully, but these errors were encountered: