public static void ConfigCookieAuth(IAppBuilder app, string loginPath
            , ICookieAuthenticationProvider cookieProvider = null)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information
            // about a user logging in with a third party login provider
            // Configure the sign in cookie
            IDataProtector cookieDataProtector = app.CreateDataProtector(
                    typeof(CookieAuthenticationMiddleware).FullName,
                    CookieAuthType, "v1");
            CookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = CookieAuthType,
                CookieName = CookieName,
                LoginPath = new PathString(loginPath),
                TicketDataFormat = new TicketDataFormat(cookieDataProtector)
            };

            if (cookieProvider != null)
            {
                CookieOptions.Provider = cookieProvider;
            }

            app.UseCookieAuthentication(CookieOptions);
        }
 public AccountController(IdentityManager identityManager, OAuthAuthorizationServerOptions oAuthOptions,
     CookieAuthenticationOptions cookieOptions)
 {
     IdentityManager = identityManager;
     OAuthOptions = oAuthOptions;
     CookieOptions = cookieOptions;
 }
        private static void ConfigureMembershipReboot(IAppBuilder app)
        {
            var cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = MembershipRebootOwinConstants.AuthenticationType
            };
            Func<IDictionary<string, object>, UserAccountService> uaFunc = env =>
            {
                var appInfo = new OwinApplicationInformation(
                    env,
                    "Test",
                    "Test Email Signature",
                    "/Login",
                    "/Register/Confirm/",
                    "/Register/Cancel/",
                    "/PasswordReset/Confirm/");

                var config = new MembershipRebootConfiguration();
                var emailFormatter = new EmailMessageFormatter(appInfo);
                // uncomment if you want email notifications -- also update smtp settings in web.config
                config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));

                var svc = new UserAccountService(config, new DefaultUserAccountRepository());
                svc.TwoFactorAuthenticationPolicy = new OwinCookieBasedTwoFactorAuthPolicy(env);
                return svc;
            };
            Func<IDictionary<string, object>, AuthenticationService> authFunc = env =>
            {
                return new OwinAuthenticationService(cookieOptions.AuthenticationType, uaFunc(env), env);
            };

            app.UseMembershipReboot(cookieOptions, uaFunc, authFunc);
        }
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            var cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            };

            app.UseCookieAuthentication(cookieOptions);

            // Configure the db context, user manager and signin manager to use a single instance per request
            /*app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});*/
        }
Exemple #5
0
        public void Configuration(IAppBuilder app)
        {
            #region Common Auth Configuration
            CookieAuthenticationOptions options = new CookieAuthenticationOptions();
            options.AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie;
            options.LoginPath = new PathString("/account/login");
            app.UseCookieAuthentication(options);
            #endregion

            app.Map("/admin", subapp =>
                {
                    subapp.UseIdentityManager(new IdentityManagerConfiguration()
                    {
                        IdentityManagerFactory = new AspNetIdentityIdentityManagerFactory().Create
                    });
                });

            //app.UseIdentityManager(new IdentityManagerConfiguration()
            //{
            //    IdentityManagerFactory = new AspNetIdentityIdentityManagerFactory().Create
            //});

            #region Thinktecture Stuff

            #endregion
        }
 public static void UseExternalSignInCookie(this IAppBuilder app, string externalAuthenticationType, bool isPersistent = false)
 {
     CookieAuthenticationOptions cookieAuthenticationOptions = new CookieAuthenticationOptions();
     cookieAuthenticationOptions.AuthenticationType = externalAuthenticationType;
     cookieAuthenticationOptions.Provider = new CookieAuthenticationProvider() { OnResponseSignIn = c => c.Properties.IsPersistent = isPersistent };
     app.UseExternalSignInCookie(cookieAuthenticationOptions);
 }
Exemple #7
0
        private void ConfigureAuth(IAppBuilder app)
        {
            var cookieOptions = new CookieAuthenticationOptions
            {
                LoginPath = new PathString("/Account/Login"),
            };

            app.UseCookieAuthentication(cookieOptions);

            app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);

            /*
            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
                {
                    ClientId = "",
                    ClientSecret = ""
                });
            */

            app.UseEnumAuthentication(new EnumAuthenticationOptions
            {
                //put here your client id and client secret
                ClientId = "",
                ClientSecret = ""
            });
        }
 public AccountController(UserManager<CampusDaysUser> identityManager, OAuthAuthorizationServerOptions oAuthOptions,
     CookieAuthenticationOptions cookieOptions)
 {
     UserManager = identityManager;
     OAuthOptions = oAuthOptions;
     CookieOptions = cookieOptions;
 }
Exemple #9
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301883
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            var cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            };
            app.UseCookieAuthentication(cookieOptions);

            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});

            //Enable Mixed Authentication
            //As we are using LogonUserIdentity, its required to run in PipelineStage.PostAuthenticate
            //Register this after any middleware that uses stage marker PipelineStage.Authenticate
            //See http://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline
            app.UseMixedAuth(cookieOptions);
        }
Exemple #10
0
        public static void Configuration(IAppBuilder appBuilder)
        {
            var cfgReader = new WebConfigReader();
            var cookieAuthenticationOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = ConstantStrings.AuthorizationCookieName,
                LoginPath = new PathString("/Login")
            };
            appBuilder.UseCookieAuthentication(cookieAuthenticationOptions);

            appBuilder.UseFacebookAuthentication(new FacebookAuthenticationOptions
            {
                AppId = cfgReader.FacebookAppId,
                AppSecret = cfgReader.FacebookAppSecret,
                Scope =
                    {
                        "email"
                    },
                SignInAsAuthenticationType = ConstantStrings.AuthorizationCookieName,
                BackchannelHttpHandler = new FacebookBackChannelHandler(),
                UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email",
                Provider = new FacebookAuthenticationProvider
                {
                    OnAuthenticated = (context) =>
                    {
                        //context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
                        ////foreach (var claim in context.User)
                        ////{
                        //    //var claimType = string.Format("urn:facebook:{0}", claim.Key);
                        //    //string claimValue = claim.Value.ToString();
                        //    //if (!context.Identity.HasClaim(claimType, claimValue))
                        //    //{
                        //        //context.Identity.AddClaim(new System.Security.Claims.Claim(claimType, claimValue, "XmlSchemaString", "Facebook"));
                        //    //}

                        ////}

                        return Task.FromResult(0);
                    }
                }
            });

            //appBuilder.UseTwitterAuthentication(new TwitterAuthenticationOptions
            //{
            //    ConsumerKey = cfgReader.TwitterConsumerKey,
            //    ConsumerSecret = cfgReader.TwitterConsumerSecret,
            //    SignInAsAuthenticationType = ConstantStrings.AuthorizationCookieName,
            //    BackchannelCertificateValidator = null   // can be for demo purposes
            //});


            appBuilder.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
            {
                ClientId = cfgReader.GoogleClientId,
                ClientSecret = cfgReader.GoogleClientSecret,
                SignInAsAuthenticationType = ConstantStrings.AuthorizationCookieName
            });
        }
 public void Configuration(IAppBuilder app) {
     app.UseCors(CorsOptions.AllowAll);
     var options = new CookieAuthenticationOptions {
         CookieName = "Token"
     };
     app.UseCookieAuthentication(options);
     app.Use<CustomLoginMiddleware>();
     app.MapSignalR(new HubConfiguration {EnableDetailedErrors = true});
 }
Exemple #12
0
 private void ConfigureAuth(IAppBuilder app)
 {
     var cookieOptions = new CookieAuthenticationOptions
     {
         LoginPath = new PathString("/Member/Login")
     };
     app.UseCookieAuthentication(cookieOptions);
     app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);
 }
Exemple #13
0
 public void Configuration(IAppBuilder app)
 {
     string strUseRedis = CloudConfigurationManager.GetSetting("UseRedis") ?? "false";
     bool useRedis = bool.Parse(strUseRedis);
     var dependencyResolver = new UnityDependencyResolver();
     UnityWireupConfiguration.WireUp(dependencyResolver);
     GlobalHost.DependencyResolver = dependencyResolver;
     var options = new CookieAuthenticationOptions()
     {
         AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
         LoginPath = new PathString("/"),
         LogoutPath = new PathString("/")
     };
     app.UseCookieAuthentication(options);
     app.Use(async (context, next) =>
     {
         if (context.Request.Path.Value.Equals("/") ||
         context.Request.Path.Value.StartsWith("/public", StringComparison.CurrentCultureIgnoreCase))
         {
             await next();
         }
         else if (context.Request.User == null || !context.Request.User.Identity.IsAuthenticated)
         {
             context.Response.StatusCode = 401;
         }
         else
         {
             await next();
         }
     });
     HttpConfiguration webApiConfiguration = new HttpConfiguration();
     webApiConfiguration.DependencyResolver = dependencyResolver;
     webApiConfiguration.MapHttpAttributeRoutes();
     app.UseWebApi(webApiConfiguration);
     RedisConfiguration redisConfiguration = dependencyResolver.Resolve<RedisConfiguration>();
     if (redisConfiguration.UseRedis)
     {
         GlobalHost.DependencyResolver.UseRedis(redisConfiguration.HostName, redisConfiguration.Port, redisConfiguration.Password, redisConfiguration.EventKey);
     }
     app.MapSignalR();
     var sharedOptions = new SharedOptions()
     {
         RequestPath = new PathString(string.Empty),
         FileSystem =
             new PhysicalFileSystem(".//public//content")
     };
     app.UseDefaultFiles(new Microsoft.Owin.StaticFiles.DefaultFilesOptions(sharedOptions)
     {
         DefaultFileNames = new List<string>() { "index.html" }
     });
     app.UseStaticFiles("/public");
     app.UseStaticFiles("/content");
     app.UseStaticFiles("/scripts");
     app.UseStaticFiles("/styles");
     app.UseStaticFiles(new StaticFileOptions(sharedOptions));
 }
Exemple #14
0
		public void Configuration(IAppBuilder app)
		{
			var authenticationOptions = new CookieAuthenticationOptions
			{
				AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
				LoginPath = new PathString("/Authorization/Login"),
			};

			app.UseCookieAuthentication(authenticationOptions);
		}
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            var cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            };

            app.UseCookieAuthentication(cookieOptions);
        }
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
            GlobalFilters.Filters.Add(new AuthorizeAttribute());

            CookieAuthenticationOptions options =new CookieAuthenticationOptions();
            options.AuthenticationType = "ApplicationCookie";
            options.LoginPath = new PathString("/Auth/Login");
            app.UseCookieAuthentication(options);
        }
 private static void ConfigureMembershipReboot(IAppBuilder app)
 {
     System.Data.Entity.Database.SetInitializer(new System.Data.Entity.MigrateDatabaseToLatestVersion<DefaultMembershipRebootDatabase, BrockAllen.MembershipReboot.Ef.Migrations.Configuration>());
     var cookieOptions = new CookieAuthenticationOptions
     {
         AuthenticationType = MembershipRebootOwinConstants.AuthenticationType
     };
     BuildAutofacContainer(app, cookieOptions.AuthenticationType);
     app.UseMembershipReboot(cookieOptions);
 }
        /// <summary>
        /// Adds a cookie-based authentication middleware to your web application pipeline.
        /// </summary>
        /// <param name="app">The IAppBuilder passed to your configuration method</param>
        /// <param name="options">An options class that controls the middleware behavior</param>
        /// <param name="stage"></param>
        /// <returns>The original app parameter</returns>
        public static IAppBuilder UseCookieAuthentication(this IAppBuilder app, CookieAuthenticationOptions options, PipelineStage stage)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }

            app.Use(typeof(CookieAuthenticationMiddleware), app, options);
            app.UseStageMarker(stage);
            return app;
        }
        public void Configuration(IAppBuilder app)
        {
            var cookie = new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookie",
                ExpireTimeSpan = TimeSpan.FromMinutes(20),
                LoginPath = new PathString("/Login"),
            };
            app.UseCookieAuthentication(cookie);

            app.UseResourceAuthorization(new ChinookAuthorization());
        }
        public static IAppBuilder UseCookieAuthentication(
            this IAppBuilder app,
            CookieAuthenticationOptions options,
            DataProtectionProvider dataProtectionProvider,
            PipelineStage stage = PipelineStage.Authenticate)
        {
            var dataProtector = dataProtectionProvider.CreateProtector(
                "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type
                options.AuthenticationType, "v2");
            options.TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector));

            return app.UseCookieAuthentication(options, stage);
        }
 public static void UseExternalSignInCookie(this IAppBuilder app, CookieAuthenticationOptions cookieAuthenticationOptions)
 {
     if (app == null)
     {
         throw new ArgumentNullException("app");
     }
     string externalAuthenticationType = cookieAuthenticationOptions.AuthenticationType;
     app.SetDefaultSignInAsAuthenticationType(externalAuthenticationType);
     cookieAuthenticationOptions.AuthenticationMode = AuthenticationMode.Passive;
     cookieAuthenticationOptions.CookieName = ".AspNet." + externalAuthenticationType;
     cookieAuthenticationOptions.ExpireTimeSpan = TimeSpan.FromMinutes(5.0);
     CookieAuthenticationExtensions.UseCookieAuthentication(app, cookieAuthenticationOptions);
 }
        static Startup()
        {
            PublicClientId = "self";

            IdentityManagerFactory = new IdentityManagerFactory(IdentityConfig.Settings, () => new IdentityStore());

            CookieOptions = new CookieAuthenticationOptions();

            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = "/Token",
                AuthorizeEndpointPath = "/api/Account/ExternalLogin",
                Provider = new ApplicationOAuthProvider(PublicClientId, IdentityManagerFactory, CookieOptions)
            };
        }
        private void ConfigureAuth(IAppBuilder app)
        {
            var cookieOptions = new CookieAuthenticationOptions
                {
                    LoginPath = new PathString("/Account/Login")
                };

            app.UseCookieAuthentication(cookieOptions);

            app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
                {
                    ClientId = GoogleClientId,
                    ClientSecret = GoogleClientSecret
                });
        }
        /// <summary>
        /// Adds a mixed-authentication middleware to your web application pipeline.
        /// </summary>
        /// <param name="app">The IAppBuilder passed to your configuration method</param>
        /// <param name="options">An options class that controls the middleware behavior</param>
        /// <param name="cookieOptions">An options class that controls the middleware behavior</param>
        /// <returns>The original app parameter</returns>
        public static IAppBuilder UseMixedAuth(this IAppBuilder app,
            MixedAuthOptions options,
            CookieAuthenticationOptions cookieOptions)
        {
            if (app == null)
                throw new ArgumentNullException("app");
            if (options == null)
                throw new ArgumentNullException("options");
            if (cookieOptions == null)
                throw new ArgumentNullException("cookieOptions");

            options.CookieOptions = cookieOptions;

            app.Use(typeof(MixedAuthMiddleware), app, options);

            app.UseStageMarker(PipelineStage.PostAuthenticate);

            return app;
        }
        private void SetupAuth(IAppBuilder app, IKernel kernel)
        {
            var options = new CookieAuthenticationOptions
            {
                LoginPath = "/login",
                LogoutPath = "/logout",
                CookieHttpOnly = true,
                AuthenticationType = "EmailR",
                CookieName = "emailr.id",
                ExpireTimeSpan = TimeSpan.FromDays(30),
                Provider = kernel.Get<ICookieAuthenticationProvider>()
            };

            app.UseCookieAuthentication(options);

            app.Use(typeof (WindowsPrincipalHandler));

            app.UseStageMarker(PipelineStage.Authenticate);
        }
        protected override void AttachToOwinApp(ConfigurationService config, IAppBuilder app)
        {
            var cookieSecurity = config.Current.RequireSSL ? 
                CookieSecureOption.Always : 
                CookieSecureOption.Never;

            var options = new CookieAuthenticationOptions()
            {
                AuthenticationType = AuthenticationTypes.LocalUser,
                AuthenticationMode = AuthenticationMode.Active,
                CookieHttpOnly = true,
                CookieSecure = cookieSecurity,
                LoginPath = new PathString("/users/account/LogOn")
            };
            
            BaseConfig.ApplyToOwinSecurityOptions(options);
            app.UseCookieAuthentication(options);
            app.SetDefaultSignInAsAuthenticationType(AuthenticationTypes.LocalUser);
        }
        public IEnumerable<OwinMiddlewareRegistration> GetOwinMiddlewares() {
            var middlewares = new List<OwinMiddlewareRegistration>();

            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

            var openIdOptions = new OpenIdConnectAuthenticationOptions {
                ClientId = _azureClientId,
                Authority = string.Format(CultureInfo.InvariantCulture, _azureADInstance, _azureTenant),
                PostLogoutRedirectUri = _logoutRedirectUri,
                Notifications = new OpenIdConnectAuthenticationNotifications ()
            };

            var cookieOptions = new CookieAuthenticationOptions();

            var bearerAuthOptions = new WindowsAzureActiveDirectoryBearerAuthenticationOptions {
                TokenValidationParameters = new TokenValidationParameters {
                    ValidAudience = string.Format(_sslEnabled ? "https://{0}/{1}" : "http://{0}/{1}", _azureTenant, _azureAppName)
                }
            };

            if (_azureWebSiteProtectionEnabled) {
                middlewares.Add(new OwinMiddlewareRegistration {
                    Priority = "9",
                    Configure = app => { app.SetDataProtectionProvider(new MachineKeyProtectionProvider()); }
                });
            }

            middlewares.Add(new OwinMiddlewareRegistration {
                Priority = "10",
                Configure = app => {
                    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

                    app.UseCookieAuthentication(cookieOptions);

                    app.UseOpenIdConnectAuthentication(openIdOptions);

                    //This is throwing an XML DTD is prohibited error?
                    //app.UseWindowsAzureActiveDirectoryBearerAuthentication(bearerAuthOptions);
                }
            });

            return middlewares;
        }
Exemple #28
0
        public void Configuration(IAppBuilder app)
        {
            var authenticationOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
            };

            IoC.Container.Inject(app.GetDataProtectionProvider());


            app.UseCookieAuthentication(authenticationOptions);

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "36549352207-0ojph3l4nmf9fjg4a2qbhntk7k8jj8md.apps.googleusercontent.com",
                ClientSecret = "IZdGnAyyUwgOE0pU6QckZE3D"
            });
        }
Exemple #29
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            var settings = new CookieAuthenticationOptions
            {
                SlidingExpiration = true,
                ExpireTimeSpan = TimeSpan.FromDays(30.0),
                CookieName = "WhoaverseLogin", //We keeping it old school with the cookies.
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            };

            //for local testing don't set cookiedomain
            var domain = WebConfigurationManager.AppSettings["CookieDomain"];
            if (!String.IsNullOrEmpty(domain))
            {
                settings.CookieDomain = domain;
            }

            app.UseCookieAuthentication(settings);

        }
        public ApplicationOAuthProvider(string publicClientId, IIdentityManagerFactory identityManagerFactory,
            CookieAuthenticationOptions cookieOptions)
        {
            if (publicClientId == null)
            {
                throw new ArgumentNullException("publicClientId");
            }

            if (identityManagerFactory == null)
            {
                throw new ArgumentNullException("_identityManagerFactory");
            }

            if (cookieOptions == null)
            {
                throw new ArgumentNullException("cookieOptions");
            }

            _publicClientId = publicClientId;
            _identityManagerFactory = identityManagerFactory;
            _cookieOptions = cookieOptions;
        }
        /// <summary>
        /// Initializes a <see cref="OapCookieAuthenticationMiddleware"/>
        /// </summary>
        /// <param name="next">The next middleware in the OWIN pipeline to invoke</param>
        /// <param name="app">The OWIN application</param>
        /// <param name="options">Configuration options for the middleware</param>
        public OapCookieAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions options) : base(next, options)
        {
            Options.Provider = Options.Provider ?? new CookieAuthenticationProvider();

            if (String.IsNullOrEmpty(Options.CookieName))
            {
                Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Options.AuthenticationType;
            }

            _logger = app.CreateLogger <OapCookieAuthenticationMiddleware>();

            if (Options.TicketDataFormat == null)
            {
                IDataProtector dataProtector = app.CreateDataProtector(
                    typeof(OapCookieAuthenticationMiddleware).FullName,
                    Options.AuthenticationType, "v1");

                Options.TicketDataFormat = new TicketDataFormat(dataProtector);
            }
            if (Options.CookieManager == null)
            {
                Options.CookieManager = new ChunkingCookieManager();
            }
        }