public static IServiceCollection AddAppUpdates(this IServiceCollection services, Action <AppUpdatesOptions> appUpdatesOptions) { var o = new AppUpdatesOptions(); appUpdatesOptions.Invoke(o); services.AddAuthentication(AuthenticationSettings.CookieAuthenticationScheme).AddCookie(AuthenticationSettings.CookieAuthenticationScheme, options => { options.Cookie.Name = AuthenticationSettings.CookieName; options.LoginPath = "/appupdates/account/login"; options.LogoutPath = "/appupdates/account/logout"; }); services.AddAuthentication(AuthenticationSettings.AuthenticationScheme).AddJwtBearer(AuthenticationSettings.AuthenticationScheme, options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = o.TokenOptions.Issuer, ValidAudience = o.TokenOptions.Audience, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(o.TokenOptions.SecurityKey)) }; }); services.Configure <FormOptions>(options => options.MultipartBodyLengthLimit = o.MaxFileUploadSizeBytes); services.AddSingleton(o.TokenOptions); services.AddSingleton <UpdateManager>(serviceProvider => new UpdateManager(o.ManifestUri, o.ClientCredentials, serviceProvider.GetService <ILoggerFactory>().CreateLogger <UpdateManager>())); return(services); }
public static IWebHostBuilder UseAppUpdates(this IWebHostBuilder hostBuilder, Action <AppUpdatesOptions> appUpdatesOptions) { var o = new AppUpdatesOptions(); appUpdatesOptions.Invoke(o); hostBuilder.UseKestrel(options => options.Limits.MaxRequestBodySize = o.MaxFileUploadSizeBytes); return(hostBuilder); }