Пример #1
0
 public AuthController(AuthService auth, AuthProviderService provs, PagesManagerService pages, ElasticService elastic, AppConfigService cfgProvider, AppDbContext db)
 {
     _auth        = auth;
     _provs       = provs;
     _pages       = pages;
     _elastic     = elastic;
     _cfgProvider = cfgProvider;
     _db          = db;
 }
Пример #2
0
 public AuthController(
     AuthService auth,
     AuthProviderService provs,
     PagesManagerService pages,
     ISearchEngine search,
     BonsaiConfigService cfgProvider,
     AppDbContext db
     )
 {
     _auth        = auth;
     _provs       = provs;
     _pages       = pages;
     _search      = search;
     _cfgProvider = cfgProvider;
     _db          = db;
 }
Пример #3
0
        /// <summary>
        /// Configures the auth-related sessions.
        /// </summary>
        private void ConfigureAuthServices(IServiceCollection services)
        {
            services.AddAuthorization(opts =>
            {
                opts.AddPolicy(AuthRequirement.Name, p => p.Requirements.Add(new AuthRequirement()));
                opts.AddPolicy(AdminAuthRequirement.Name, p => p.Requirements.Add(new AdminAuthRequirement()));
            });

            services.AddScoped <IAuthorizationHandler, AuthHandler>();
            services.AddScoped <IAuthorizationHandler, AdminAuthHandler>();

            var auth         = services.AddAuthentication(IdentityConstants.ApplicationScheme);
            var authProvider = new AuthProviderService();

            authProvider.Initialize(Configuration, auth);
            services.AddSingleton(authProvider);

            services.ConfigureApplicationCookie(opts =>
            {
                opts.LoginPath          = "/auth/login";
                opts.AccessDeniedPath   = "/auth/login";
                opts.ReturnUrlParameter = "returnUrl";
            });
        }