I had two specific desires of my Jwt secrets used for signing. They are provided via a secrets.json file created/managed on deployed servers and integrated into the IConfiguration workflow.
- I wanted Jwt secrets updatable in the configuration file and have updates applied to my Jwt verification process without the need to restart the application(s).
- I wanted the ability to have some FastEndpoints endpoints to support a secondary/alternate Jwt secret for signing verification.
The basic flow is the following.
- Add Jwt support via FastEndpoints
Services.AddAuthenticationJwtBearerextenion method (if not using FastEndpoints, look at this helper method to see what manually needs to be done, but mostly it is just call toAddAuthenticationandAddJwtBearer(with appropriate settings)). - Add a
IConfigureOptionssingleton to the service collection and provide aIssuerSigningKeyResolverdelegate. (Note: this needed to be anIConfigureOptionsinstead of s