/// <summary> /// Create an instance of the options initialized with the default values /// </summary> public CookieAuthenticationOptions() { AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; CookieHttpOnly = true; CookieSecure = CookieSecureOption.SameAsRequest; SystemClock = new SystemClock(); Notifications = new CookieAuthenticationNotifications(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add Entity Framework services to the services container. services.AddEntityFramework() .AddSqlServer() .AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration["Data:CRMDBConnection:ConnectionString"])); // Add Identity services to the services container. services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>(); services.ConfigureIdentity(conf => { conf.Password.RequiredLength = 6; conf.Password.RequireLowercase = false; conf.Password.RequireDigit = false; conf.Password.RequireNonLetterOrDigit = false; conf.Password.RequireUppercase = false; conf.User.UserNameValidationRegex = null; }); // Configure the options for the authentication middleware. // You can add options for Google, Twitter and other middleware as shown below. // For more information see http://go.microsoft.com/fwlink/?LinkID=532715 services.Configure<FacebookAuthenticationOptions>(options => { options.AppId = Configuration["Authentication:Facebook:AppId"]; options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }); services.Configure<MicrosoftAccountAuthenticationOptions>(options => { options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"]; options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"]; }); services.ConfigureCookieAuthentication(options => { CookieAuthenticationNotifications cookieAuthN = options.Notifications as CookieAuthenticationNotifications; if (cookieAuthN == null) { cookieAuthN = new CookieAuthenticationNotifications(); options.Notifications = cookieAuthN; } cookieAuthN.OnApplyRedirect = ctx => { if (IsAjaxRequest(ctx.Request) == false) { ctx.Response.Redirect(ctx.RedirectUri); } }; }); // Add MVC services to the services container. services.AddMvc(); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); // Register application services. services.AddTransient<IEmailSender, AuthMessageSender>(); services.AddTransient<ISmsSender, AuthMessageSender>(); services.AddReact(); }