diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 3aebb419f8..79d1b3c3fe 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -13,6 +13,13 @@ namespace CookieSample { public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(); } diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 9ad9e6841e..c35dfd9998 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -14,6 +14,13 @@ namespace CookieSessionSample { public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); } diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 9df41a9ab7..030e640c99 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -43,6 +43,13 @@ namespace JwtBearerSample // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }); + services.AddJwtBearerAuthentication(o => { // You also need to update /wwwroot/app/scripts/app.js diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index e69563ced1..875762d126 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,6 +7,10 @@ aspnet5-OpenIdConnectSample-20151210110318 + + + + @@ -25,4 +29,8 @@ + + + + diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index b4d24505d5..87e7755084 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -23,16 +23,12 @@ namespace OpenIdConnectSample }) .UseKestrel(options => { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + options.Listen(IPAddress.Loopback, 44318, listenOptions => { - // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - } + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 96bce512d5..a712b6c03f 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -21,16 +21,12 @@ namespace SocialSample }) .UseKestrel(options => { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + options.Listen(IPAddress.Loopback, 44318, listenOptions => { - // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - } + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index e0336cc0e3..723d74de32 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,6 +7,14 @@ aspnet5-SocialSample-20151210111056 + + + + + + + + diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index ffffa46460..0039720096 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -164,11 +164,6 @@ namespace SocialSample o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; - o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); - o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); - o.ClaimActions.MapJsonKey("urn:github:name", "name"); - o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); - o.ClaimActions.MapJsonKey("urn:github:url", "url"); }); // You must first create an app with GitHub and add its ID and Secret to your user-secrets. @@ -184,6 +179,11 @@ namespace SocialSample o.ClaimsIssuer = "OAuth2-Github"; o.SaveTokens = true; // Retrieving user information is unique to each provider. + o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); + o.ClaimActions.MapJsonKey("urn:github:name", "name"); + o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + o.ClaimActions.MapJsonKey("urn:github:url", "url"); o.Events = new OAuthEvents { OnCreatingTicket = async context => diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 408789b037..257aed9cb1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.DependencyInjection { public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); } public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions)