public CryptionService( Microsoft.Extensions.Configuration.IConfiguration config, ILogger <CryptionService> logger) { this.Logger = logger; symmetric = Aes.Create(); symmetric.Mode = CipherMode.CBC; symmetric.Padding = PaddingMode.ISO10126; symmetric.KeySize = 256; symmetric.Key = Convert.FromBase64String(config.GetSection("CRYPTION_KEY").Value); symmetric.IV = Convert.FromBase64String(config.GetSection("CRYPTION_IV").Value); hash = new HMACSHA512(Convert.FromBase64String(config.GetSection("CRYPTION_HASH").Value)); symmetric2 = Aes.Create(); symmetric2.Mode = CipherMode.CBC; symmetric2.Padding = PaddingMode.ISO10126; symmetric2.KeySize = 256; symmetric2.Key = Convert.FromBase64String(config.GetSection("CRYPTION_KEY2").Value); symmetric2.IV = Convert.FromBase64String(config.GetSection("CRYPTION_IV2").Value); }
public TimedHostedService(IConfiguration configuration, ILogger <TimedHostedService> logger, IServiceScopeFactory scopeFactory) { _logger = logger; _scopeFactory = scopeFactory; try { _enabled = bool.Parse(configuration["Scheduler:Enabled"]); _immediate = bool.Parse(configuration["Scheduler:Immediate"]); _interval = int.Parse(configuration["Scheduler:Interval"]); _scheduledTime = DateTime.Parse(configuration["Scheduler:ScheduledTime"]); _userId = configuration["Scheduler:UserId"]; _itemCountEnabled = bool.Parse(configuration["Scheduler:ItemCountEnabled"]); } catch (Exception ex) { _enabled = false; _logger.LogError(ex.ToString()); } }
public CommunityController(INoticeViewModel noticeViewModel, IFaqViewModel faqViewModel, INoticeService noticeService, IFaqService faqService, IHttpContextAccessor accessor, IQnaViewModel qnaViewModel, IQnaService qnaService, IHostingEnvironment hostingEnvironment, Microsoft.Extensions.Configuration.IConfiguration configuration) { _noticeService = noticeService; _noticeViewModel = noticeViewModel; _faqViewModel = faqViewModel; _faqService = faqService; _accessor = accessor; _qnaViewModel = qnaViewModel; _qnaService = qnaService; _hostingEnvironment = hostingEnvironment; _configuration = configuration; }
public static ApplicationSettings CreateApplicationSettingsStandard(Microsoft.Extensions.Configuration.IConfiguration configurationRoot = null, string migrationAssembly = null) { if (configurationRoot == null) { var configurationBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder(); Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(configurationBuilder, "appsettings.json", optional: false, reloadOnChange: true); configurationRoot = configurationBuilder.Build(); } var connectionStringMap = new Routines.Configuration.Standard.ConnectionStringMap(configurationRoot); var connectionString = connectionStringMap.GetConnectionString("AdminkaConnectionString"); var adminkaStorageConfiguration = new AdminkaStorageConfiguration(connectionString, migrationAssembly, StorageType.SQLSERVER, migrationAssembly == null?default(int?):5 * 60); var appSettings = new Routines.Configuration.Standard.AppSettings(configurationRoot); var configurationManagerLoader = new Routines.Configuration.Standard.ConfigurationManagerLoader(configurationRoot); var configurationContainerFactory = ResetConfigurationContainerFactoryStandard(configurationManagerLoader); var unhandledExceptionLogging = new NUnhandledExceptionLogging(); return(new ApplicationSettings(appSettings, configurationContainerFactory, unhandledExceptionLogging, adminkaStorageConfiguration)); }
public MessagingProfile(Microsoft.Extensions.Configuration.IConfiguration config) { ConfigureEndpoint("Events") .AsInboundOutbound() .BindEvent <PaymentMethodCreated>() //see AuzureKeyVaultSample for a better way .UseAesEncryption(config.GetSection("SampleAESKey").Value) .UseLocalTransport() ; ConfigureEndpoint("Commands") .AsInboundOutbound() .UseLocalTransport() ; ConfigureEndpoint("Replies") .AsInboundOutbound() .AsReplyDefault() .UseLocalTransport() ; }
public DatabaseOperations(Microsoft.Extensions.Configuration.IConfiguration conf, SPMiddlewareOptions sPMiddlewareOptions, SwaggerFromSPOptions options, SqlHelper sqlHelper, ILogger <DatabaseOperations> logger, DbConnection dbConnection, ParameterProvider parametersProvider, NamingMappingHandler namingMappingHandler) { this.sPMiddlewareOptions = sPMiddlewareOptions; this.options = options; this.sqlHelper = sqlHelper; this.logger = logger; this.dbConnection = dbConnection; this.parametersProvider = parametersProvider; this.namingMappingHandler = namingMappingHandler; var ent = conf.GetSection("Entities"); entities = ent.GetChildren() .Select(s => Entity.GetFromSection(s)).ToList(); }
public static void AddJWT(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; var issuer = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:SecretKey"])); options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = configuration["Jwt:Issuer"], ValidAudience = configuration["Jwt:Audience"], IssuerSigningKey = issuer, ClockSkew = TimeSpan.Zero }; }); }
public void AddServices(IServiceCollection services, IConfiguration configuration) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IAccessTokenProvider, AccessTokenProvider>(); services.AddSingleton <ICustomerAccessTokenProvider, CustomerAccessTokenProvider>(); var featureOptions = new FeatureFolderOptions(); services.AddMvc(options => options.Filters.Add(typeof(ReauthenticationRequiredFilter))) .AddFeatureFolders(featureOptions).AddRazorOptions(o => o.ViewLocationFormats.Add(featureOptions.FeatureNamePlaceholder + "/{1}/{0}.cshtml")); RegisterAuthorizationPolicies(services); RegisterMappers(services); services.AddDistributedRedisCache(redisCacheOptions => { redisCacheOptions.Configuration = configuration["Redis:Configuration"]; redisCacheOptions.InstanceName = configuration["Redis:InstanceName"]; }); AddAuthentication(services, configuration); }
public UsersController(RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager, Microsoft.Extensions.Configuration.IConfiguration configuration) { Genders = new List <SelectListItem> { new SelectListItem { Value = "0", Text = "Neznámé" }, new SelectListItem { Value = "1", Text = "Muž" }, new SelectListItem { Value = "2", Text = "Žena" }, new SelectListItem { Value = "3", Text = "Jiné" } }; _roleManager = roleManager; _userManager = userManager; Configuration = configuration; iconSize = Convert.ToInt32(Configuration["Profile:IconSize"]); pictureSize = Convert.ToInt32(Configuration["Profile:PictureSize"]); }
public static IServiceCollection AddIdentityServices(this IServiceCollection services, IConfiguration config) { var builder = services.AddIdentityCore <AppUser>(); builder = new IdentityBuilder(builder.UserType, builder.Services); builder.AddEntityFrameworkStores <AppIdentityDbContext>(); builder.AddSignInManager <SignInManager <AppUser> >(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(config["Token:key"])), ValidIssuer = config["Token:Issuer"], ValidateIssuer = true, ValidateAudience = false }; }); return(services); }
public static void ConfigureServices(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) { configuration.GetSection <AdminSettings>(); services.AddApplicationServices(); services.AddRepositories(); services.AddSwager(); //services.AddCors(options => //{ // options.AddPolicy("CorsPolicy", // builder => builder.AllowAnyOrigin() // .AllowAnyMethod() // .AllowAnyHeader() // .AllowCredentials()); //}); //services.AddMvc(options => //{ // //options.Filters.Add(typeof(LogFilterAttribute)); // options.Filters.Add(typeof(CustomExceptionFilter)); // //options.ModelBinderProviders.Insert(0, new CustomBinderProvider()); //}).AddSessionStateTempDataProvider().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddJwt(configuration); configuration.GetSection <RahyabParameters>(); services.AddScoped <IContext, MainContext>(); //services.AddDbContext<MainContext>(o => o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("Infrastructure.EndPoint"))); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IEncrypter, Encrypter>(); services.AddScoped <INotification, RahyabService>(); configuration.GetSection <RahyabParameters>(); services.AddJwt(configuration); services.AddScoped <IContext, MainContext>(); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IEncrypter, Encrypter>(); services.AddScoped <INotification, RahyabService>(); services.AddScoped <IFireBase, FireBase>(); }
public static void SetSecurity(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) { var tokenConfigurations = new TokenConfiguration(); var signingConfigurations = new SigningConfigurations(); new ConfigureFromConfigurationOptions <TokenConfiguration>( configuration.GetSection("TokenConfigurations") ) .Configure(tokenConfigurations); services.AddSingleton(tokenConfigurations); services.AddSingleton(signingConfigurations); ///TODO Core services.AddAuthentication(authOptions => { authOptions.DefaultAuthenticateScheme = Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme; authOptions.DefaultChallengeScheme = Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(bearerOptions => { var paramsValidation = bearerOptions.TokenValidationParameters; paramsValidation.IssuerSigningKey = signingConfigurations.SecurityKey; paramsValidation.ValidAudience = tokenConfigurations.Audience; paramsValidation.ValidIssuer = tokenConfigurations.Issuer; paramsValidation.ValidateIssuerSigningKey = true; paramsValidation.ValidateLifetime = true; paramsValidation.ClockSkew = System.TimeSpan.Zero; }); services.AddAuthorization(auth => { auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder() .AddAuthenticationSchemes(Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build()); }); }
public void AddServices(IServiceCollection services, IConfiguration configuration) { services.Configure <AuthenticationOptions>(configuration.GetSection("Authentication:AzureAd")); services.Configure <B2CAuthenticationOptions>(configuration.GetSection("Authentication:AzureAd:B2C")); services.Configure <B2CPolicies>(configuration.GetSection("Authentication:AzureAd:B2C:Policies")); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IAccessTokenProvider, AccessTokenProvider>(); services.AddSingleton <ICustomerAccessTokenProvider, CustomerAccessTokenProvider>(); var featureOptions = new FeatureFolderOptions(); services.AddMvc().AddFeatureFolders(featureOptions).AddRazorOptions(o => o.ViewLocationFormats.Add(featureOptions.FeatureNamePlaceholder + "/{1}/{0}.cshtml")); RegisterAuthorizationPolicies(services); RegisterMappers(services); services.AddDistributedRedisCache(redisCacheOptions => { redisCacheOptions.Configuration = configuration["Redis:Configuration"]; redisCacheOptions.InstanceName = configuration["Redis:InstanceName"]; }); }
public void RegisterDependencies(Container iocContainer, Microsoft.Extensions.Configuration.IConfiguration config) { Log.Debug("Registering common bootstrappers"); var assembliesToRegister = Bootstrappers .Where(b => b.HasDomainComponents) .Select(GetAssemblyFromBootstrapper) .ToList(); var componentsRegistrars = Bootstrappers .Select(b => b.DomainComponentDependencyRegistrar) .Where(r => r != null) .ToList(); foreach (var registrar in componentsRegistrars) { registrar.RegisterCommonDependencies(iocContainer, assembliesToRegister); } Log.Debug("Registering individual bootstrappers"); foreach (var bootstrapper in Bootstrappers) { RunAction(p => p.RegisterDependencies(iocContainer, config), bootstrapper, "Register Dependencies"); } }
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddConfiguration(this Microsoft.Extensions.Configuration.IConfigurationBuilder configurationBuilder, Microsoft.Extensions.Configuration.IConfiguration config) { throw null; }
public Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader Configure(Microsoft.Extensions.Configuration.IConfiguration config) { throw null; }
public static string GetConnectionString(this Microsoft.Extensions.Configuration.IConfiguration configuration, string name) { throw null; }
public static System.Collections.Generic.IEnumerable <System.Collections.Generic.KeyValuePair <string, string> > AsEnumerable(this Microsoft.Extensions.Configuration.IConfiguration configuration, bool makePathsRelative) { throw null; }
public static bool ParseBool(Microsoft.Extensions.Configuration.IConfiguration configuration, string key) { throw null; }
public WebHostOptions(Microsoft.Extensions.Configuration.IConfiguration configuration, string applicationNameFallback) { }
public WebHostOptions(Microsoft.Extensions.Configuration.IConfiguration configuration) { }
/// <summary> /// 构造方法 /// </summary> /// <param name="configuration"></param> public AuthVisitorService(Microsoft.Extensions.Configuration.IConfiguration configuration) { _tokenOptions = TokenProviderOptions.Load(configuration); }
public Startup(Microsoft.Extensions.Configuration.IConfiguration configuration) : base(configuration) { }
internal static System.IO.Stream ResolveManifest(Microsoft.AspNetCore.Hosting.IWebHostEnvironment environment, Microsoft.Extensions.Configuration.IConfiguration configuration) { throw null; }
public DefaultConfigurationSource(Microsoft.Extensions.Configuration.IConfiguration configuration) { _configuration = configuration; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConfiguration(this Microsoft.Extensions.Logging.ILoggingBuilder builder, Microsoft.Extensions.Configuration.IConfiguration configuration) { throw null; }
public void WithConfigurationSource(Microsoft.Extensions.Configuration.IConfiguration configuration) { _builder.WithConfigurationSource(new DefaultConfigurationSource(configuration)); }
/// <summary> /// Configure container /// </summary> /// <param name="container">ContainerBuilder from autofac</param> /// <param name="configuration">configuration</param> public static void ConfigureContainer(this ContainerBuilder container, Microsoft.Extensions.Configuration.IConfiguration configuration) { EngineContext.Current.ConfigureContainer(container, configuration); }
public Startup(IConfiguration configuration) { Configuration = configuration; }
public GenericWebHostService(Microsoft.Extensions.Options.IOptions <Microsoft.AspNetCore.Hosting.GenericWebHostServiceOptions> options, Microsoft.AspNetCore.Hosting.Server.IServer server, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.AspNetCore.Http.IHttpContextFactory httpContextFactory, Microsoft.AspNetCore.Hosting.Builder.IApplicationBuilderFactory applicationBuilderFactory, System.Collections.Generic.IEnumerable <Microsoft.AspNetCore.Hosting.IStartupFilter> startupFilters, Microsoft.Extensions.Configuration.IConfiguration configuration, Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment) { }