Startup.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Configuration;
  3. using Abp.Owin;
  4. using Microsoft.Owin;
  5. using Microsoft.Owin.Cors;
  6. using Microsoft.Owin.Security.Cookies;
  7. using Owin;
  8. using WeEngine;
  9. using WeEngine.Api;
  10. using WeEngine.Api.Controllers;
  11. [assembly: OwinStartup(typeof(Startup))]
  12. namespace WeEngine
  13. {
  14. public class Startup
  15. {
  16. public void Configuration(IAppBuilder app)
  17. {
  18. app.UseAbp();
  19. app.UseCors(CorsOptions.AllowAll);
  20. app.UseOAuthBearerAuthentication(AccountController.OAuthBearerOptions);
  21. app.UseCookieAuthentication(new CookieAuthenticationOptions
  22. {
  23. AuthenticationType = WeEngineAuthenticationTypes.ApplicationCookie,
  24. LoginPath = new PathString("/Account/Index"),
  25. // by setting following values, the auth cookie will expire after the configured amount of time (default 14 days) when user set the (IsPermanent == true) on the login
  26. ExpireTimeSpan = new TimeSpan(int.Parse(ConfigurationManager.AppSettings["AuthSession.ExpireTimeInDays.WhenPersistent"] ?? "14"), 0, 0, 0),
  27. SlidingExpiration = bool.Parse(ConfigurationManager.AppSettings["AuthSession.SlidingExpirationEnabled"] ?? bool.TrueString),
  28. //SessionStore = new IwbAuthenticationSessionStore()
  29. });
  30. app.UseExternalSignInCookie(WeEngineAuthenticationTypes.ExternalCookie);
  31. app.UseOAuthAuthorizationServer(OAuthOptions.CreateServerOptions());
  32. //app.MapSignalR();
  33. //ENABLE TO USE HANGFIRE dashboard (Requires enabling Hangfire in WeEngineWebModule)
  34. //app.UseHangfireDashboard("/hangfire", new DashboardOptions
  35. //{
  36. // Authorization = new[] { new AbpHangfireAuthorizationFilter() } //You can remove this line to disable authorization
  37. //});
  38. }
  39. }
  40. }