Having a configuration similar to this:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(x =>
{
x.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false,
ValidateAudience = false,
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(config.JwtSecret)),
ValidateLifetime = true,
ClockSkew = TimeSpan.Zero
};
});
Is there a proper way of changing the IssuerSigningKey during runtime?
Ideas that come to mind:
keep a reference to TokenValidationParameters and just replace the IssuerSigningKey
extend SymmetricSecurityKey and do something similar as in the previous point
Both of these ways seem too hacky. I assume there is some kind of mechanism to achieve this the right way, I just couldn't find it.