You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm struggling a bit to understand how to reach my requirements.
I am in a context where, to support efficiently our integration tests, where I use a test server from Microsoft.AspNetCore.Mvc.Testing, we want to override some behaviors to help tests run quickly, using the dependency injection.
For this reason, I need to use an injection configuration when initializing authentication, rather than a resolved configuration.
For AddJwtBearer, I have overrides to the extensions methods, that allow me to do the following:
services.ConfigureOptions<ConfigureJwtBearerOptions>();services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(JwtBearerDefaults.AuthenticationScheme);publicclassConfigureJwtBearerOptions:IConfigureNamedOptions<JwtBearerOptions>{privatereadonlyAppSettings_appSettings;// allows to have injected configurationpublicConfigureJwtBearerOptions(IOptions<AppSettings>appSettingsOptions){_appSettings=appSettingsOptions.Value;}publicvoidConfigure(JwtBearerOptionsoptions){// use injected configurationoptions.Instance=_appSettings.Instance;}publicvoidConfigure(stringname,JwtBearerOptionsoptions){Configure(options);}}
However, when using AddMicrosoftIdentityWebApi, based on the available extension methods, I seem to have to provide either a IConfiguration or a IConfigurationSection (resolved configurations then) in all overrides.
I tried passing empty Actions to the latest override and to provide IConfigureOptions, IConfigureNamedOptions, IPostConfigureOptions 😓, but I did not manage to have the option configuration methods to be called.
Is there a way to make this work ? Would this need an evolution of the library ? If so, would such an evolution be considered reasonable, or are they blockers to this approach ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm struggling a bit to understand how to reach my requirements.
I am in a context where, to support efficiently our integration tests, where I use a test server from
Microsoft.AspNetCore.Mvc.Testing
, we want to override some behaviors to help tests run quickly, using the dependency injection.For this reason, I need to use an injection configuration when initializing authentication, rather than a resolved configuration.
For
AddJwtBearer
, I have overrides to the extensions methods, that allow me to do the following:However, when using
AddMicrosoftIdentityWebApi
, based on the available extension methods, I seem to have to provide either aIConfiguration
or aIConfigurationSection
(resolved configurations then) in all overrides.I tried passing empty Actions to the latest override and to provide
IConfigureOptions
,IConfigureNamedOptions
,IPostConfigureOptions
😓, but I did not manage to have the option configuration methods to be called.Is there a way to make this work ? Would this need an evolution of the library ? If so, would such an evolution be considered reasonable, or are they blockers to this approach ?
Thanks a lot,
Beta Was this translation helpful? Give feedback.
All reactions