Skip to content

Commit

Permalink
Take the auth0 configuration out of the configure callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Dec 18, 2022
1 parent 23a6c31 commit ab67f3c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Todo.Web/Server/Authentication/AuthenticationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,14 @@ public static WebApplicationBuilder AddAuthentication(this WebApplicationBuilder
["GitHub"] = static (builder, configure) => builder.AddGitHub(configure),
["Google"] = static (builder, configure) => builder.AddGoogle(configure),
["Microsoft"] = static (builder, configure) => builder.AddMicrosoftAccount(configure),
["Auth0"] = static (builder, configure) =>
{
builder.AddAuth0WebAppAuthentication(configure);
// TODO: Support tokens from auth0 natively
// .WithAccessToken(configure);
},
["Auth0"] = static (builder, configure) => builder.AddAuth0WebAppAuthentication(configure)
// .WithAccessToken(configure),
};

foreach (var (providerName, provider) in externalProviders)
{
var section = builder.Configuration.GetSection($"Authentication:Schemes:{providerName}");

if (section.Exists())
{
provider(authenticationBuilder, options =>
Expand All @@ -73,9 +70,14 @@ public static WebApplicationBuilder AddAuthentication(this WebApplicationBuilder
{
// Skip the cookie handler since we already add it
auth0WebAppOptions.SkipCookieMiddleware = true;
SetAuth0SignInScheme(builder);
}
});

if (providerName is "Auth0")
{
// Set this up once
SetAuth0SignInScheme(builder);
}
}
}

Expand Down

0 comments on commit ab67f3c

Please sign in to comment.