Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.Configure <SSRNMGlobal>(Configuration.GetSection("Paths"));
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = "ClientCertificateAuthentication";
            })
            .AddDrtAuthentication()
            .AddClientCertificateAuthentication(options =>
                                                ClientCertificateAuthenticationOptions.CreateForOnlyDoDRoots());

            MapperFactory.Init();
            services.AddAutoMapper(typeof(DtoMappingProfile));



            services.AddControllers();
            services.AddHttpContextAccessor();



            services.AddDbContext <SSRNMFSSNContext>(options =>
            {
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            });

            services.AddScoped <DbContext>();
            services.AddScoped <SSRNMFSSNContext>();
            services.AddScoped <ReportRepository>();
            services.AddScoped <ReportDomain>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <UserDomain>();
            //services.AddDataProtection();


            services.AddTransient <EmailService>(options =>
            {
                EmailServiceOptions eoptions = new EmailServiceOptions();
                Configuration.GetSection("EmailService").Bind(eoptions);
                var emailService = new EmailService(eoptions);
                return(emailService);
            });
        }
Exemple #2
0
        public static IAppBuilder UseClientCertificateAuthentication(this IAppBuilder app, X509RevocationMode revocationMode = X509RevocationMode.Online, bool createExtendedClaims = false)
        {
            var policy = new X509ChainPolicy
            {
                RevocationMode = revocationMode
            };

            var validator = X509CertificateValidator.CreateChainTrustValidator(true, policy);

            var options = new ClientCertificateAuthenticationOptions
            {
                Validator = validator,
                CreateExtendedClaimSet = createExtendedClaims
            };

            return(app.UseClientCertificateAuthentication(options));
        }
Exemple #3
0
 public static IAppBuilder UseClientCertificateAuthentication(this IAppBuilder app, ClientCertificateAuthenticationOptions options)
 {
     app.Use <ClientCertificateAuthenticationMiddleware>(options);
     return(app);
 }
        public static IAppBuilder UseClientCertificateAuthentication(this IAppBuilder appBuilder)
        {
            var options = new ClientCertificateAuthenticationOptions();

            return(appBuilder.UseClientCertificateAuthentication(options));
        }