Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 36d3d97

Browse files
committed
#1319 Add DisplayName overloads
1 parent 5485846 commit 36d3d97

File tree

19 files changed

+67
-16
lines changed

19 files changed

+67
-16
lines changed

samples/OpenIdConnect.AzureAdSample/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void ConfigureServices(IServiceCollection services)
4949
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
5050
})
5151
.AddCookie()
52-
.AddOpenIdConnect(o =>
52+
.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, "AAD", o =>
5353
{
5454
o.ClientId = ClientId;
5555
o.ClientSecret = ClientSecret; // for code flow

samples/SocialSample/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void ConfigureServices(IServiceCollection services)
7070
})
7171
// You must first create an app with Google and add its ID and Secret to your user-secrets.
7272
// https://console.developers.google.com/project
73-
.AddOAuth("Google-AccessToken", o =>
73+
.AddOAuth("Google-AccessToken", "Google AccessToken only", o =>
7474
{
7575
o.ClientId = Configuration["google:clientid"];
7676
o.ClientSecret = Configuration["google:clientsecret"];
@@ -128,7 +128,7 @@ public void ConfigureServices(IServiceCollection services)
128128
*/
129129
// You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets.
130130
// https://apps.dev.microsoft.com/
131-
.AddOAuth("Microsoft-AccessToken", o =>
131+
.AddOAuth("Microsoft-AccessToken", "Microsoft AccessToken only", o =>
132132
{
133133
o.ClientId = Configuration["microsoftaccount:clientid"];
134134
o.ClientSecret = Configuration["microsoftaccount:clientsecret"];
@@ -148,7 +148,7 @@ public void ConfigureServices(IServiceCollection services)
148148
})
149149
// You must first create an app with GitHub and add its ID and Secret to your user-secrets.
150150
// https://github.com/settings/applications/
151-
.AddOAuth("GitHub-AccessToken", o =>
151+
.AddOAuth("GitHub-AccessToken", "GitHub AccessToken only", o =>
152152
{
153153
o.ClientId = Configuration["github-token:clientid"];
154154
o.ClientSecret = Configuration["github-token:clientsecret"];

src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder
2121
=> builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions);
2222

2323
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action<CookieAuthenticationOptions> configureOptions)
24+
=> builder.AddCookie(authenticationScheme, displayName: null, configureOptions: configureOptions);
25+
26+
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<CookieAuthenticationOptions> configureOptions)
2427
{
2528
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
26-
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, configureOptions);
29+
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, displayName, configureOptions);
2730
}
2831
}
2932
}

src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public static class FacebookDefaults
77
{
88
public const string AuthenticationScheme = "Facebook";
99

10+
public static readonly string DisplayName = "Facebook";
11+
1012
public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.6/dialog/oauth";
1113

1214
public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.6/oauth/access_token";

src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder build
1616
=> builder.AddFacebook(FacebookDefaults.AuthenticationScheme, configureOptions);
1717

1818
public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action<FacebookOptions> configureOptions)
19-
=> builder.AddOAuth<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
19+
=> builder.AddFacebook(authenticationScheme, FacebookDefaults.DisplayName, configureOptions);
20+
21+
public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<FacebookOptions> configureOptions)
22+
=> builder.AddOAuth<FacebookOptions, FacebookHandler>(authenticationScheme, displayName, configureOptions);
2023
}
2124
}

src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public static class GoogleDefaults
1010
{
1111
public const string AuthenticationScheme = "Google";
1212

13+
public static readonly string DisplayName = "Google";
14+
1315
public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth";
1416

1517
public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token";

src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder
1616
=> builder.AddGoogle(GoogleDefaults.AuthenticationScheme, configureOptions);
1717

1818
public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action<GoogleOptions> configureOptions)
19-
=> builder.AddOAuth<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
19+
=> builder.AddGoogle(authenticationScheme, GoogleDefaults.DisplayName, configureOptions);
20+
21+
public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<GoogleOptions> configureOptions)
22+
=> builder.AddOAuth<GoogleOptions, GoogleHandler>(authenticationScheme, displayName, configureOptions);
2023
}
2124
}

src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder buil
1818
=> builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, configureOptions);
1919

2020
public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action<JwtBearerOptions> configureOptions)
21+
=> builder.AddJwtBearer(authenticationScheme, displayName: null, configureOptions: configureOptions);
22+
23+
public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<JwtBearerOptions> configureOptions)
2124
{
2225
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
23-
return builder.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
26+
return builder.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, displayName, configureOptions);
2427
}
2528
}
2629
}

src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public static class MicrosoftAccountDefaults
77
{
88
public const string AuthenticationScheme = "Microsoft";
99

10+
public static readonly string DisplayName = "Microsoft";
11+
1012
public static readonly string AuthorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize";
1113

1214
public static readonly string TokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token";

src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuild
1616
=> builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions);
1717

1818
public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
19-
=> builder.AddOAuth<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
19+
=> builder.AddMicrosoftAccount(authenticationScheme, MicrosoftAccountDefaults.DisplayName, configureOptions);
20+
21+
public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<MicrosoftAccountOptions> configureOptions)
22+
=> builder.AddOAuth<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, displayName, configureOptions);
2023
}
2124
}

0 commit comments

Comments
 (0)