CommunitySolidServer: Solid-client-authn-browser silent authentication is not granted refresh_token
The intended behaviour with restorePreviousSession is to receive an access_token (default ttl 60min) and a refresh_token (ttl 24h) with prompt=none rather than prompt=consent.
As discussed at https://github.com/solid/community-server/issues/909, deviating from prompt=consent is not entirely consistent with the OIDC spec. However, requiring prompt=consent means that consent is required at every page refresh, and not providing a refresh_token means that authorised operations are not possible after 60min without repeating authentication and consent again.
At the moment it seems the intention of CSS is to assume consent if the user has selected “remember”, and the UI implies that the user will not need to provide consent again for some unspecified time/a number of future authentications.
However, rejectedScopes does not accept offline_access when shouldRemember is true, it merely avoids rejecting it. Removal of the offline_access scope occurs at https://github.com/panva/node-oidc-provider/blob/d7a5ba5ba191d5af8e4bed9449cbb43a3d5a1619/lib/actions/authorization/check_scope.js#L34
This can be tested with a token request with scope=“openid offline_access” and prompt=none, as is issued by solid-client-authn-browser when refreshing a logged in page with restorePreviousSession=true. Refresh_token is not provided in the response.
As discussed at https://github.com/panva/node-oidc-provider/blob/main/docs/README.md#refresh-tokens and https://github.com/panva/node-oidc-provider/blob/main/docs/README.md#issuerefreshtoken this behaviour can be changed by overriding the issueRefreshToken function in the config: https://github.com/solid/community-server/blob/a1579f625a68ac97096ed476a55075a748258453/src/identity/configuration/IdentityProviderFactory.ts#L136 However, it’s not clear to me how the “remember” status would be accessed from this function. The following function obviously returns a refresh token for every token request:
async function issueRefreshToken(ctx, client, code) {
if (!client.grantTypeAllowed('refresh_token')) {
return false;
}
return true;
}
config.issueRefreshToken=issueRefreshToken;
A workaround is to keep the default restorePreviousSession=false, so consent is requested every time and the refresh_token is consistently issued.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 16 (8 by maintainers)
I’d like to reopen this issue, as having a refresh token after silent authentication would be very useful. Users expect an app to stay logged in for more than an hour even after a page refresh.
In 2024 what are the barriers to this?
P.S. I set up a little app that lets you test CSS tokens with a 30 second ttl to confirm that this behavior still happens and it does. Refreshing the token works during the initial login, but fail after you reload the page and go through silent login.
The default ttl for an access token is 60min https://github.com/solid/community-server/blob/5a01f09f814f81b50d0372d9efad710fe5fd0460/config/identity/handler/provider-factory/identity.json#L42
I have also experienced requests being rejected because the access token has expired, i.e. solid-client-authn-browser did not succeed in replacing it.
Yes, solid-client-authn-browser does look like it has some code that can do a prompt=none request in an iframe, but I haven’t worked out how to use it - the default definitely is using refresh tokens.
And yes, a page refresh will also refresh the access token with prompt=none, though that’s not really a solution. Incidentally at the moment consent is needed again after 60min even with a page refresh, but that’s just because the default ttl of an idtoken is also 60min, i.e. solid-client-authn-browser fails to load the user details from localStorage because the idtoken has expired. https://github.com/solid/community-server/blob/5a01f09f814f81b50d0372d9efad710fe5fd0460/config/identity/handler/provider-factory/identity.json#L45 Whether to lengthen the default on that is a separate issue. I’ve set it to 24h on my pod.
Edit: expiry of the idtoken is no longer relevant as solid-client-authn-browser no longer uses the idtoken for restorePreviousSession https://github.com/inrupt/solid-client-authn-js/commit/f0b715c1939457f03e5ce44810cb2cbad6798018