Example #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseAbp(options => { options.UseAbpRequestLocalization = false; }); //Initializes ABP framework.

            app.UseAuthentication();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();
            app.UseRouting();

            //app.UseJwtTokenMiddleware();

            app.UseAuthorization();

            CorsConfigurer.Use(app);
            MvcConfigurer.Use(app);
            SwaggerConfigurer.Use(app, _appConfiguration);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #2
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <JTDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddJTIdentity <Tenant, User, Role>()
            .AddJTTenantManager <JTTenantManager <Tenant, User> >()
            .AddJTUserManager <UserManager>()
            .AddJTRoleManager <RoleManager>()
            .AddJTEditionManager <JTEditionManager>()
            .AddJTUserStore <UserStore>()
            .AddJTUserStore <JTUserStore <Role, User> >()
            .AddJTRoleStore <RoleStore>()
            .AddJTLogInManager <JTLogInManager <Tenant, Role, User> >()
            .AddJTSignInManager <JTSignInManager <Tenant, Role, User> >()
            .AddJTSecurityStampValidator <JTSecurityStampValidator <Tenant, Role, User> >()
            .AddJTUserClaimsPrincipalFactory <UserClaimsPrincipalFactory>()
            .AddJTPermissionChecker <PermissionChecker>()
            .AddDefaultTokenProviders();

            CorsConfigurer.Configure(services);
            AuthConfigurer.Configure(services, _appConfiguration);
            MvcConfigurer.Configure(services);
            SwaggerConfigurer.Configure(services, _appConfiguration);

            services.AddControllersWithViews(options =>
            {
                //options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
                options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <JTWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }