// This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddIdentityServer()
            .AddTemporarySigningCredential()
            .AddTestUsers(IdentityConfig.GetTestUsers())
            .AddInMemoryApiResources(IdentityConfig.GetApiResources())
            .AddInMemoryIdentityResources(IdentityConfig.GetIdentityResources())
            .AddInMemoryClients(IdentityConfig.GetClients());

            services.AddMvc();
        }
示例#2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMultiTenancy <TenantResolutionFromTokenValidationLibrary>();

            services.AddEarlyLogging(out var earlyLogger);
            earlyLogger.LogInformation("starting to configure services...");

            services.AddCors(options => options.AddPolicy("mycustomcorspolicy", b => b.WithOrigins("http://meinetollewebsite.de").AllowAnyMethod().AllowAnyHeader()));
            services.AddMvc();

            services.AddSingleton <IConfigureOptions <CookieAuthenticationOptions>, ConfigureCookieOptions>();
            services.AddIdentityServer()
            .AddSigningCredentialFromKeyVault(config, earlyLogger)
            .AddInMemoryIdentityResources(IdentityConfig.GetIdentityResources())
            .AddInMemoryApiResources(IdentityConfig.GetApis())
            .AddInMemoryApiScopes(IdentityConfig.GetScopes())
            .AddInMemoryClients(IdentityConfig.GetClients())
            .AddTestUsers(IdentityConfig.GetTestUsers())
            ;

            services.AddScoped <DisposeTest>();
            services.AddAuthentication();
            services.AddAuthorization(o =>
            {
                o.AddPolicy("default", b =>
                {
                    b.RequireAuthenticatedUser();
                    b.RequireClaim(JwtClaimTypes.Subject);//windows authenticated but no authenticated cookie (logged out) shouldbe treated as unauthenticated.
                });
            });

            services.AddTransient <RequestFromOnPremise>();

            services.AddTransientDecorator <ICorsPolicyProvider, CorsPolicyProvider>();
            services.AddTransientDecorator <IAuthorizeRequestValidator, ExtendedAuthorizeRequestValidator>();

            services.AddSingleton <IResolvedTenant>(new ResolvedTenant("default"));

            earlyLogger.LogInformation("done configuring general services :)");
        }