Skip to content

Commit

Permalink
Merge pull request #579 from akunzai/simplify-oidc
Browse files Browse the repository at this point in the history
Simplify OIDC configuration for samples
  • Loading branch information
akunzai authored Apr 14, 2024
2 parents e1c2cca + 4da3e50 commit 49a9892
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 28 deletions.
6 changes: 1 addition & 5 deletions samples/AspNetCoreIdentitySample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@
options.ClientId = builder.Configuration["OIDC:ClientId"];
options.ClientSecret = builder.Configuration["OIDC:ClientSecret"];
options.Authority = builder.Configuration["OIDC:Authority"];
options.MetadataAddress = builder.Configuration["OIDC:MetadataAddress"];
options.RequireHttpsMetadata = !builder.Environment.IsDevelopment();
options.SaveTokens = builder.Configuration.GetValue("OIDC:SaveTokens", false);
options.ResponseType =
builder.Configuration.GetValue("OIDC:ResponseType", OpenIdConnectResponseType.Code)!;
options.ResponseMode =
builder.Configuration.GetValue("OIDC:ResponseMode", OpenIdConnectResponseMode.Query)!;
options.ResponseType = OpenIdConnectResponseType.Code;
var scope = builder.Configuration["OIDC:Scope"];
if (!string.IsNullOrWhiteSpace(scope))
{
Expand Down
6 changes: 1 addition & 5 deletions samples/AspNetCoreReactSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,9 @@ await context.Options.Events.RedirectToLogout(new RedirectContext<CookieAuthenti
options.ClientId = builder.Configuration["OIDC:ClientId"];
options.ClientSecret = builder.Configuration["OIDC:ClientSecret"];
options.Authority = builder.Configuration["OIDC:Authority"];
options.MetadataAddress = builder.Configuration["OIDC:MetadataAddress"];
options.RequireHttpsMetadata = !builder.Environment.IsDevelopment();
options.SaveTokens = builder.Configuration.GetValue("OIDC:SaveTokens", false);
options.ResponseType =
builder.Configuration.GetValue("OIDC:ResponseType", OpenIdConnectResponseType.Code)!;
options.ResponseMode =
builder.Configuration.GetValue("OIDC:ResponseMode", OpenIdConnectResponseMode.Query)!;
options.ResponseType = OpenIdConnectResponseType.Code;
var scope = builder.Configuration["OIDC:Scope"];
if (!string.IsNullOrWhiteSpace(scope))
{
Expand Down
6 changes: 1 addition & 5 deletions samples/AspNetCoreSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,9 @@ await context.Options.Events.RedirectToLogout(new RedirectContext<CookieAuthenti
options.ClientId = builder.Configuration["OIDC:ClientId"];
options.ClientSecret = builder.Configuration["OIDC:ClientSecret"];
options.Authority = builder.Configuration["OIDC:Authority"];
options.MetadataAddress = builder.Configuration["OIDC:MetadataAddress"];
options.RequireHttpsMetadata = !builder.Environment.IsDevelopment();
options.SaveTokens = builder.Configuration.GetValue("OIDC:SaveTokens", false);
options.ResponseType =
builder.Configuration.GetValue("OIDC:ResponseType", OpenIdConnectResponseType.Code)!;
options.ResponseMode =
builder.Configuration.GetValue("OIDC:ResponseMode", OpenIdConnectResponseMode.Query)!;
options.ResponseType = OpenIdConnectResponseType.Code;
var scope = builder.Configuration["OIDC:Scope"];
if (!string.IsNullOrWhiteSpace(scope))
{
Expand Down
6 changes: 1 addition & 5 deletions samples/BlazorSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@ await context.Options.Events.RedirectToLogout(new RedirectContext<CookieAuthenti
options.ClientId = builder.Configuration["OIDC:ClientId"];
options.ClientSecret = builder.Configuration["OIDC:ClientSecret"];
options.Authority = builder.Configuration["OIDC:Authority"];
options.MetadataAddress = builder.Configuration["OIDC:MetadataAddress"];
options.RequireHttpsMetadata = !builder.Environment.IsDevelopment();
options.SaveTokens = builder.Configuration.GetValue("OIDC:SaveTokens", false);
options.ResponseType =
builder.Configuration.GetValue("OIDC:ResponseType", OpenIdConnectResponseType.Code)!;
options.ResponseMode =
builder.Configuration.GetValue("OIDC:ResponseMode", OpenIdConnectResponseMode.Query)!;
options.ResponseType = OpenIdConnectResponseType.Code;
var scope = builder.Configuration["OIDC:Scope"];
if (!string.IsNullOrWhiteSpace(scope))
{
Expand Down
10 changes: 2 additions & 8 deletions samples/OwinSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,11 @@ public void Configuration(IAppBuilder app)
ClientId = configuration["OIDC:ClientId"],
ClientSecret = configuration["OIDC:ClientSecret"],
Authority = configuration["OIDC:Authority"],
MetadataAddress = configuration["OIDC:MetadataAddress"],
RequireHttpsMetadata = !env.Equals("Development", StringComparison.OrdinalIgnoreCase),
SaveTokens = configuration.GetValue("OIDC:SaveTokens", false),
ResponseType =
configuration.GetValue("OIDC:ResponseType", OpenIdConnectResponseType.Code),
ResponseMode =
configuration.GetValue("OIDC:ResponseMode", OpenIdConnectResponseMode.Query),
ResponseType = OpenIdConnectResponseType.Code,
// https://github.com/aspnet/AspNetKatana/issues/348
RedeemCode =
configuration.GetValue("OIDC:ResponseType", OpenIdConnectResponseType.Code)
.Contains(OpenIdConnectResponseType.Code),
RedeemCode = true,
Scope = configuration.GetValue("OIDC:Scope", OpenIdConnectScope.OpenIdProfile),
TokenValidationParameters = { NameClaimType = configuration.GetValue("OIDC:NameClaimType", "name") },
// https://github.com/aspnet/AspNetKatana/wiki/System.Web-response-cookie-integration-issues
Expand Down

0 comments on commit 49a9892

Please sign in to comment.