Startup.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 WePlatform;
  9. using WePlatform.Api;
  10. using WePlatform.Api.Controllers;
  11. using WePlatform.Configuration;
  12. [assembly: OwinStartup(typeof(Startup))]
  13. namespace WePlatform
  14. {
  15. public class Startup
  16. {
  17. public void Configuration(IAppBuilder app)
  18. {
  19. app.UseAbp();
  20. app.UseCors(CorsOptions.AllowAll);
  21. app.UseOAuthBearerAuthentication(AccountController.OAuthBearerOptions);
  22. app.UseCookieAuthentication(new CookieAuthenticationOptions
  23. {
  24. AuthenticationType = IwbAuthenticationTypes.ApplicationCookie,
  25. LoginPath = new PathString("/Account/Index"),
  26. // 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
  27. ExpireTimeSpan = new TimeSpan(int.Parse(ConfigurationManager.AppSettings["AuthSession.ExpireTimeInDays.WhenPersistent"] ?? "14"), 0, 0, 0),
  28. SlidingExpiration = bool.Parse(ConfigurationManager.AppSettings["AuthSession.SlidingExpirationEnabled"] ?? bool.TrueString),
  29. //SessionStore = new IwbAuthenticationSessionStore()
  30. });
  31. app.UseExternalSignInCookie(IwbAuthenticationTypes.ExternalCookie);
  32. app.UseOAuthAuthorizationServer(OAuthOptions.CreateServerOptions());
  33. app.MapSignalR();
  34. //ENABLE TO USE HANGFIRE dashboard (Requires enabling Hangfire in WePlatformWebModule)
  35. //app.UseHangfireDashboard("/hangfire", new DashboardOptions
  36. //{
  37. // Authorization = new[] { new AbpHangfireAuthorizationFilter() } //You can remove this line to disable authorization
  38. //});
  39. }
  40. }
  41. }