Replies: 4 comments 10 replies
-
it seems that the session expires, not the access token, hence refreshing the access token fails because the session is gone the XHR/PUT request should not lead to a redirect: either protect it explicitly with after receiving the 401 the SPA needs to trigger a full authentication roundtrip i.e. by refreshing the parent window |
Beta Was this translation helpful? Give feedback.
-
Thanks very much Hans for the quick response. Yes, that makes sense that it's the session expiring in terms of the error I'm seeing (I was looking at the source code and decided this was the case). I'm a bit confused about why it's happening, given, in the log I provided, we see these two lines: I'd thought that when the inactivity timeout happened (after 10 seconds), I had up until the session max lifetime (10 days) to be able to refresh using the refresh token - but that's not the case? Re the 401 - I guess the problem is that a user a) loads the page, b) starts editing stuff, thinking, editing - has their changes ready to go and wants to c) go save (PUT) them - so I want that save mechanism to work reliably. It's possible there's a significant time delay between a) and b) too. Refreshing the parent window (as things stand now) will lose the changes they've just made. Hence my attempt to automatically re-authenticate on failure, using the refresh token, then try the save (PUT) again. Are you saying there's no way to reliably reauthenticate and retry the save - even if I set the SessionMaxDuration to be huge, despite that being, as best I can tell, what the user probably wants (short of somehow passing the save data to the parent window again)? |
Beta Was this translation helpful? Give feedback.
-
I'm running into the same situation - we have a Mediawiki instance protected by mod_auth_openidc. The user starts editing a page and if they submit their changes after the timeout occurs the edits are lost because the PUT fails. This is a pretty bad user experience. I can bump Does https://github.com/zmartzone/mod_auth_openidc/wiki/OpenID-Connect-Session-Management have any bearing on this issue? I tried adding that to our pages, but it doesn't appear to help. I'm seeing 404's in the logs for the URLs I added:
I suppose another idea would be to add an edit countown timer to the page to warn a user that their session is about to expire. Does mod_auth_openidc have any method for that? Should it? Otherwise, thanks for a great module, it's very helpful. |
Beta Was this translation helpful? Give feedback.
-
see also here: |
Beta Was this translation helpful? Give feedback.
-
Hi,
First - thanks very much for your module, it works great (when I drive it correctly!)
I've got an SPA using apache (2.4.52), your module (2.4.9.4) and Azure AD as identity provider.
On initial page load, everything works perfectly - meaning
a) the main page loads, redirects, authenticates, etc
b) various XHR GETs all work, via the same authenticated path
c) saving data with PUTs works too.
After something times out though, when a PUT is requested, it fails, gets redirected, and then I hit a CORS error trying to authenticate it as Azure AD hasn't provided Access Control headers to allow it.
I've seen some suggestions that I need to configure Azure to know it's an SPA, to get it to add appropriate Access Control headers - but when I do that, Azure won't let me log in at all - complaining (IIRC) the it needs PKCE, which I tried enabling with all three OIDCPKCEMethod settings but Azure was never happy.
So - I'm trying a different path. The PUT works initially. So my current attempt (there's been a few, eg setting OIDCRefreshAccessTokenBeforeExpiry so that I'd never see any issues with timeouts - not sure why this didn't work for me) is to detect when the PUT fails, then send to
<redirect_uri>?refresh=<return_to>&access_token=<access_token>
to refresh the access token, then try my PUT again.
The problem is, I'm getting
oidc_handle_refresh_token_request: no existing access_token found in the session, nothing to refresh
The session key seems to be correct, but it's getting a cache miss.
The config I'm changing is I think limited to:
OIDCProviderMetadataURL https://login.microsoftonline.com/XXXXX/v2.0/.well-known/openid-configuration
OIDCClientID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
OIDCClientSecret XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
OIDCRedirectURI https://XXXXX.XXXXX.XXX/${customername}/${customerservice}/auth/redirect
OIDCCryptoPassphrase XXXXXXXXXXXXXXXXXXXXXXXXX
OIDCSessionMaxDuration 864000
OIDCSessionInactivityTimeout 10
OIDCCookie rta_openidc_session
OIDCScope "openid email profile offline_access"
OIDCRemoteUserClaim preferred_username
OIDCPassRefreshToken On
OIDCPassClaimsAs both
OIDCRefreshAccessTokenBeforeExpiry 10
OIDCInfoHook access_token id_token
And here's the logs I presume to be relevant - hopefully the redaction hasn't obscured anything:
access_token_refresh.log.gz
Thanks very much for any help you can offer,
John
PS I think I've found similar discussions - but "extend the timeouts" was sometimes the main solution, which doesn't feel right to me.
Beta Was this translation helpful? Give feedback.
All reactions