public static IApplicationBuilder UseSimpleTokenAuthentication(this IApplicationBuilder app, SimpleTokenAuthenticationOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrEmpty(options.AuthenticationScheme)) { options.AuthenticationScheme = "Bearer"; } if (options.SecurityTokenValidatorsFactory == null) { // TODO: fix it because it is using app services, and it should use scope services, // a work around could be: // ``` // SecurityTokenValidatorsFactory = () => // { // var context = app.ApplicationServices.GetService<IHttpContextAccessor>().HttpContext; // return context.RequestServices.GetServices<ISecurityTokenValidator>(); // } // ``` options.SecurityTokenValidatorsFactory = () => app.ApplicationServices.GetServices<ISecurityTokenValidator>(); } return app.UseMiddleware<SimpleTokenAuthenticationMiddleware>(Options.Create(options)); }
public static IApplicationBuilder UseSimpleTokenAuthentication(this IApplicationBuilder app, SimpleTokenAuthenticationOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrEmpty(options.AuthenticationScheme)) { options.AuthenticationScheme = "Bearer"; } if (options.SecurityTokenValidatorsFactory == null) { // TODO: fix it because it is using app services, and it should use scope services, // a work around could be: // ``` // SecurityTokenValidatorsFactory = () => // { // var context = app.ApplicationServices.GetService<IHttpContextAccessor>().HttpContext; // return context.RequestServices.GetServices<ISecurityTokenValidator>(); // } // ``` options.SecurityTokenValidatorsFactory = () => app.ApplicationServices.GetServices <ISecurityTokenValidator>(); } return(app.UseMiddleware <SimpleTokenAuthenticationMiddleware>(Options.Create(options))); }
public static IApplicationBuilder UseSimpleTokenAuthentication(this IApplicationBuilder app, SimpleTokenAuthenticationOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); }