Beispiel #1
0
        public void Configure(IApplicationBuilder app, CommonService service)
        {
            var authOptions = new CookieAuthenticationOptions {
                AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
                AutomaticAuthenticate = true,
                AutomaticChallenge = true,
                ExpireTimeSpan = TimeSpan.FromHours(5),
                Events = new CookieAuthenticationEvents {
                    OnRedirectToLogin = context => {
                        context.Response.StatusCode = (int) HttpStatusCode.Unauthorized;
                        return Task.CompletedTask;
                    }
                }
            };

            // redirect to setup until configured
            app.MapWhen(
                ctx => ctx.Request.Path == "/" && !service.IsConfigured(),
                req => req.Run(
                    ctx => Task.Run(() => ctx.Response.Redirect("/setup"))
                )
            );
            app.UseDefaultFiles()
                .UseStaticFiles()
                .UseCookieAuthentication(authOptions)
                .UseMvc();
            CreateDatabase(app);
        }
Beispiel #2
0
 public SettingsController(GamesContext db, CommonService service, AuthenticationService auth) {
     this.db = db;
     this.service = service;
     this.auth = auth;
 }
Beispiel #3
0
 public UserController(GamesContext db, CommonService service)
 {
     this.db = db;
     this.service = service;
 }
Beispiel #4
0
 public AuthenticationService(CommonService service) {
     this.service = service;
 }
Beispiel #5
0
 public ImageController(GamesContext db, CommonService service, AuthenticationService auth, IHostingEnvironment env) {
     this.db = db;
     this.service = service;
     this.auth = auth;
     this.environment = env;
 }