Move auth config options to app settings (#20790)

* Move auth config options to app settings
* Move logging configuration setup to host builder
* Address issues from peer review
This commit is contained in:
Safia Abdalla 2020-04-14 15:29:09 -07:00 committed by GitHub
parent fc38f9e0c3
commit d03c3b2a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 13 deletions

View File

@ -160,7 +160,8 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
}
/// <summary>
/// Builds an <see cref="IConfiguration"/> with keys and values from the set of registered providers.
/// Builds an <see cref="IConfiguration"/> with keys and values from the set of providers registered in
/// <see cref="IConfigurationRoot.Providers"/>.
/// </summary>
/// <returns>An <see cref="IConfigurationRoot"/> with keys and values from the registered providers.</returns>
public IConfigurationRoot Build()

View File

@ -97,7 +97,8 @@
"Server/Data/SqlLite/**",
"Server/Data/SqlServer/**",
"Server/Data/ApplicationDbContext.cs",
"Server/Areas/**"
"Server/Areas/**",
"Client/wwwroot/appsettings.Development.json"
]
},
{
@ -127,7 +128,9 @@
"Client/Pages/Authentication.razor",
"Client/Shared/LoginDisplay.*.razor",
"Client/Shared/MainLayout.Auth.razor",
"Client/Shared/RedirectToLogin.razor"
"Client/Shared/RedirectToLogin.razor",
"Client/wwwroot/appsettings.Development.json",
"Client/wwwroot/appsettings.json"
]
},
{
@ -166,7 +169,9 @@
"Client/Pages/Authentication.razor",
"Client/Shared/LoginDisplay.*.razor",
"Client/Shared/MainLayout.Auth.razor",
"Client/Shared/RedirectToLogin.razor"
"Client/Shared/RedirectToLogin.razor",
"Client/wwwroot/appsettings.Development.json",
"Client/wwwroot/appsettings.json"
]
},
{

View File

@ -7,6 +7,7 @@ using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
#endif
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
#if (Hosted)
@ -44,18 +45,14 @@ namespace ComponentsWebAssembly_CSharp
// Configure your authentication provider options here.
// For more information, see https://aka.ms/blazor-standalone-auth
#endif
options.ProviderOptions.Authority = "https://login.microsoftonline.com/";
options.ProviderOptions.ClientId = "33333333-3333-3333-33333333333333333";
builder.Configuration.Bind("Local", options.ProviderOptions);
});
#endif
#endif
#if (IndividualB2CAuth)
builder.Services.AddMsalAuthentication(options =>
{
var authentication = options.ProviderOptions.Authentication;
authentication.Authority = "https:////aadB2CInstance.b2clogin.com/qualified.domain.name/MySignUpSignInPolicyId";
authentication.ClientId = "33333333-3333-3333-33333333333333333";
authentication.ValidateAuthority = false;
builder.Configuration.Bind("AzureAdB2C", options.ProviderOptions.Authentication);
#if (Hosted)
options.ProviderOptions.DefaultAccessTokenScopes.Add("https://qualified.domain.name/api.id.uri/api-scope");
#endif
@ -64,9 +61,7 @@ namespace ComponentsWebAssembly_CSharp
#if(OrganizationalAuth)
builder.Services.AddMsalAuthentication(options =>
{
var authentication = options.ProviderOptions.Authentication;
authentication.Authority = "https://login.microsoftonline.com/22222222-2222-2222-2222-222222222222";
authentication.ClientId = "33333333-3333-3333-33333333333333333";
builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
#if (Hosted)
options.ProviderOptions.DefaultAccessTokenScopes.Add("api://api.id.uri/api-scope");
#endif

View File

@ -0,0 +1,8 @@
{
////#if (IndividualLocalAuth)
// "Local": {
// "Authority": "https://login.microsoftonline.com/",
// "ClientId": "33333333-3333-3333-33333333333333333"
// }
////#endif
}

View File

@ -0,0 +1,22 @@
{
////#if (IndividualLocalAuth)
//"Local": {
// "Authority": "https://login.microsoftonline.com/",
// "ClientId": "33333333-3333-3333-33333333333333333"
//},
////#endif
////#if (IndividualB2CAuth)
//"AzureAdB2C": {
// "Authority": "https:////aadB2CInstance.b2clogin.com/qualified.domain.name/MySignUpSignInPolicyId",
// "ClientId": "33333333-3333-3333-33333333333333333",
// "ValidateAuthority": false
//},
////#endif
////#if (OrganizationalAuth)
//"AzureAd": {
// "Authority": "https:////login.microsoftonline.com/22222222-2222-2222-2222-222222222222",
// "ClientId": "33333333-3333-3333-33333333333333333",
// "ValidateAuthority": true
//},
////#endif
}