-
Notifications
You must be signed in to change notification settings - Fork 468
Description
Ok, I am building up my ASP.Net API Application to use the RS1024 algorithm.
services.AddAuthentication(JwtAuthenticationDefaults.AuthenticationScheme)
.AddJwt(options =>
{
options.VerifySignature = true;
});
services.AddJwtEncoder();
X509Certificate2 cert = LoadFromSecureStore();
services.AddSingleton<IAlgorithmFactory>(new DelegateAlgorithmFactory(new RS1024Algorithm(cert)));This is working, I can generate and consume the JWTs.
A year goes by, and now I want to rotate those keys. Reading through JWT it looks like I can use the kid header to give the keys id's which can be used for looking up the right cert. However I'm not sure how I would ever get access to the JWT header (or the kid) in order to select the right X509. I'm probably missing something pretty obvious.
The DelegateFactory and others do take a Func<IJwtAlgorithm> but the kid isn't passed down.
I see WithSecret is used with symmetric algo's - this makes me think I might be missing something about asymmetric algo's. 🤔
A WithKeys would be helpful and could be used in the AddJwt call too.
I'm sure I'm missing something obvious, so any help would be appreciated. Also, if I've asked in the wrong forum, please let me know and I can move this conversation there.