question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenIddict RC1 no longer issues new refresh tokens by default

See original GitHub issue

Starting with 1.0.0-rc1 and 2.0.0-rc1, OpenIddict will no longer issue a new refresh token when sending a grant_type=refresh_token token request.

Why this change?

In the previous betas, OpenIddict used a non-configurable mode codenamed “rolling tokens”: every time a refresh token was sent as part of a grant_type=refresh_token request, it was automatically revoked and a new single-use refresh token was generated and returned to the client application.

This approach was great from a security perspective but had a few downsides. For instance, it didn’t play well with heavily distributed client applications like MVC apps implementing transparent access token renewal (e.g using Microsoft’s OIDC client middleware). In such scenario, if two refresh tokens requests were simultaneously sent with the same refresh token, one of them would be automatically rejected as the refresh token would be already marked as “redeemed” when handling the second request.

How does that work now?

By default, OpenIddict will now issue a single refresh token and manage its lifetime dynamically by extending its expiration date every time it’s used in a refresh token request. This refresh token is not automatically revoked and can be used until it expires.

How do I fix my code?

If you use a standard-compliant OAuth2 client, no change should be required. Returning a new refresh token is not required and mainly an implementation decision. When no new refresh token is issued, clients are expected to keep using the refresh token used to create the original refresh token request.

The authorization server MAY issue a new refresh token, in which case the client MUST discard the old refresh token and replace it with the new refresh token. The authorization server MAY revoke the old refresh token after issuing a new refresh token to the client.

https://tools.ietf.org/html/rfc6749#section-6

What if I prefer the old “rolling tokens” approach?

The previous default behavior is still supported but is now an opt-in option. To enable it, call options.UseRollingTokens() from the OpenIddict configuration delegate, in ConfigureServices().

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
kevinchaletcommented, Sep 18, 2017

Because it’s a better default: it doesn’t have the race condition risk inherent to the rolling tokens option and it puts less stress on the database (fewer refresh tokens are stored as the same entry is reused when extending the token lifetime). Yet, the security level is still very good because the refresh token can still be revoked at any time if the client or the authorization server think it may have been compromised.

3reactions
sir-boformercommented, Nov 18, 2017

took me a while to find this after my app broke…

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenIddict Refresh Token Flow issue ASP.NET Core
If you see the The refresh token is no longer valid error returned from your own code, that likely means Identity was unable...
Read more >
Token storage - OpenIddict documentation
A token entry contains metadata like the subject of the token, the client identifier of the application it was issued to or its...
Read more >
Migrating to AspNet.Security.OpenIdConnect.Server RC1
Unfortunately, this change makes old authorization codes, access and refresh tokens incompatible with the new format (and vice versa). In ...
Read more >
Implementing OpenID Code Flow with PKCE using OpenIddict ...
This article shows how to implement the OpenID Connect Code Flow with PKCE using OpenIddict hosted in an ASP.NET Core application, an ASP....
Read more >
Setting up an Authorization Server with OpenIddict - Part VI
A refresh token allows an application to obtain a new access token without prompting the user. Enable refresh tokens. First we need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found