I am using this library https://github.com/openiddict/openiddict-core and implemented the oAuth token flow.
// Register the OpenIddict services.
// Note: use the generic overload if you need
// to replace the default OpenIddict entities.
services.AddOpenIddict(options =>
{
// Register the Entity Framework stores.
options.AddEntityFrameworkCoreStores<ApplicationDbContext>();
// Register the ASP.NET Core MVC binder used by OpenIddict.
// Note: if you don't call this method, you won't be able to
// bind OpenIdConnectRequest or OpenIdConnectResponse parameters.
options.AddMvcBinders();
// Enable the token endpoint (required to use the password flow).
options.EnableTokenEndpoint("/connect/token");
// Allow client applications to use the grant_type=password flow.
options.AllowPasswordFlow();
// During development, you can disable the HTTPS requirement.
options.DisableHttpsRequirement();
});
Mostly everything is working. I also included RoleManager along with it and roles are being stored in token as well using this:
var principal = await _signInManager.CreateUserPrincipalAsync(user);
foreach (var claim in principal.Claims.Where(c => c.Type == OpenIdConnectConstants.Claims.Role))
{
claim.SetDestinations(OpenIdConnectConstants.Destinations.AccessToken, OpenIdConnectConstants.Destinations.IdentityToken);
}
So far everything is done. After that admin user goes and modified the role to make him Supervisor
etc. At this point of role change I want to make the previous tokens invalid. Is this possible in the library because at the moment he is able to use old token which has "Maid" role and is incorrect because somebody just changed his role to "Supervisor". In this case I want that when client sends old token it should not be treated as valid and should be sent back to login page.
How do I handle this in OpenIDDict
library?