From 2978451679ef8b455406f4be26931ae30dfd400b Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 6 Jun 2016 14:59:47 +0200 Subject: [PATCH] fixe la redirection a l'authentification en echec --- Yavsc/src/Startup.cs | 51 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/Yavsc/src/Startup.cs b/Yavsc/src/Startup.cs index e004b8bf..ff597b09 100755 --- a/Yavsc/src/Startup.cs +++ b/Yavsc/src/Startup.cs @@ -7,11 +7,7 @@ using System.Reflection; using System.Security.Claims; using System.Web; using System.Web.Optimization; -using AspNet.Security.OpenIdConnect.Extensions; using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Authentication.Google; -using Microsoft.AspNet.Authentication.JwtBearer; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Builder; @@ -368,8 +364,7 @@ namespace Yavsc ClientSecret = Configuration["Authentication:Google:ClientSecret"], AccessType = "offline", SaveTokensAsClaims = true, - UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me", - AutomaticChallenge=true + UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me" }; var gvents = new OAuthEvents(); @@ -413,28 +408,6 @@ namespace Yavsc app.UseStaticFiles().UseWebSockets(); app.UseIdentity(); - - app.UseCookieAuthentication(options => - { - options.AutomaticAuthenticate = true; - options.AutomaticChallenge = true; - options.AuthenticationScheme = "ServerCookie"; - options.ExpireTimeSpan = TimeSpan.FromMinutes(5); - options.LoginPath = new PathString("/signin"); - options.LogoutPath = new PathString("/signout"); - // options.CookieName = "Bearer"; - }); - - app.UseMiddleware(googleOptions); - - // Facebook - app.UseFacebookAuthentication(options => - { - options.AppId = Configuration["Authentication:Facebook:AppId"]; - options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; - options.Scope.Add("email"); - options.UserInformationEndpoint = "https://graph.facebook.com/v2.5/me?fields=id,name,email,first_name,last_name"; - }); app.UseOpenIdConnectServer(options => { options.Provider = new AuthorizationProvider(loggerFactory, @@ -464,6 +437,28 @@ namespace Yavsc // options.ValidationEndpointPath = new PathString("/connect/introspect"); }); /**/ + app.UseCookieAuthentication(options => + { + options.AutomaticAuthenticate = true; + options.AutomaticChallenge = true; + options.AuthenticationScheme = "ServerCookie"; + options.ExpireTimeSpan = TimeSpan.FromMinutes(5); + options.LoginPath = new PathString("/signin"); + options.LogoutPath = new PathString("/signout"); + options.CookieName = "Bearer"; + }); + + app.UseMiddleware(googleOptions); + + // Facebook + app.UseFacebookAuthentication(options => + { + options.AppId = Configuration["Authentication:Facebook:AppId"]; + options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; + options.Scope.Add("email"); + options.UserInformationEndpoint = "https://graph.facebook.com/v2.5/me?fields=id,name,email,first_name,last_name"; + }); + app.UseRequestLocalization(localizationOptions.Value, (RequestCulture)new RequestCulture((string)"fr")); /* Generic OAuth (here GitHub): options.Notifications = new OAuthAuthenticationNotifications