Now, when the service receives first API request that requires authentication, the authentication handler (here, a JwtBearerHandler) attempts to fetch the OpenID configuration followed by token signing keys (from the discovery endpoint) for the authorization server. The response is cached and refreshed every 24 hours by default with the help of the property available as JwtBearerOptions.AutomaticRefreshInterval. Given, the OpenID configuration and the keys are fetched during the first API request, it adds a minor delay in the response there (especially, when the token can be tried to be validated against multiple schemes).
Therefore, we would like to identify a way in which we could request the MSAL to fetch the OpenID configuration in advance and cache it during the service collection setup phase (i.e., during the web API startup). It could be later refreshed periodically and automatically with the help of the setting available under JwtBearerOptions.AutomaticRefreshInterval.
Any pointers for achieving this would be really helpful!
Currently, we can protect a web API using the library as follows:
Now, when the service receives first API request that requires authentication, the authentication handler (here, a
JwtBearerHandler
) attempts to fetch the OpenID configuration followed by token signing keys (from the discovery endpoint) for the authorization server. The response is cached and refreshed every 24 hours by default with the help of the property available asJwtBearerOptions.AutomaticRefreshInterval
. Given, the OpenID configuration and the keys are fetched during the first API request, it adds a minor delay in the response there (especially, when the token can be tried to be validated against multiple schemes).Therefore, we would like to identify a way in which we could request the MSAL to fetch the OpenID configuration in advance and cache it during the service collection setup phase (i.e., during the web API startup). It could be later refreshed periodically and automatically with the help of the setting available under
JwtBearerOptions.AutomaticRefreshInterval
.Any pointers for achieving this would be really helpful!
Regards, Chintan Rajvir