예제 #1
0
 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());
     }
 }
예제 #3
0
 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;
 }
예제 #4
0
        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));
        }
예제 #5
0
        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()
            ;
        }
예제 #6
0
        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();
        }
예제 #7
0
 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
         };
     });
 }
예제 #8
0
        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);
        }
예제 #11
0
파일: Extension.cs 프로젝트: hiwamn/Mukta
        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>();
        }
예제 #12
0
        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;
 }
예제 #16
0
 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);
 }
예제 #23
0
 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;
 }
예제 #25
0
 public DefaultConfigurationSource(Microsoft.Extensions.Configuration.IConfiguration configuration)
 {
     _configuration = configuration;
 }
예제 #26
0
 public static Microsoft.Extensions.Logging.ILoggingBuilder AddConfiguration(this Microsoft.Extensions.Logging.ILoggingBuilder builder, Microsoft.Extensions.Configuration.IConfiguration configuration)
 {
     throw null;
 }
예제 #27
0
 public void WithConfigurationSource(Microsoft.Extensions.Configuration.IConfiguration configuration)
 {
     _builder.WithConfigurationSource(new DefaultConfigurationSource(configuration));
 }
예제 #28
0
 /// <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);
 }
예제 #29
0
 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)
 {
 }