Msal Authentication添加到服务商后能否更改Authority,ClientId,DefaultAccessTokenScopes
Can you change the Authority, ClientId, and DefaultAccessTokenScopes in Msal Authentication after adding it to the service provider
我希望能够从单个网络应用程序调用不同的应用程序寄存器。我不知道该怎么做。起初我以为我可以向我的服务提供商添加多个 MsalAuthentications,而不是调用一个特定的。我无法让它工作,所以现在我想知道是否可以更改我在开始时添加的 MsalAuthentication 的选项。
这是我添加 MSAL 身份验证的方式:
builder.Services.AddMsalAuthentication(options =>
{
var authentication = options.ProviderOptions.Authentication;
authentication.Authority = FakeADTenant.TenantAddress;
authentication.ClientId = FakeADTenant.AppId;
authentication.ValidateAuthority = true;
options.ProviderOptions.DefaultAccessTokenScopes.Add(FakeADTenant.TokenScope);
});
在另一端,当点击登录按钮时,我正在使用此页面登录:
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />
@code{
[Parameter] public string Action { get; set; }
}
我想我可以在调用 RemoteAuthenticatorView 之前更改代码中的选项。我只想更改 authentication.Authority、authentication.ClientId 和 options.ProviderOptions.DefaultAccessTokenScopes。
不,作为任何 OAuth 提供者,您不能更改 clientId,The Authority 是 OAuth 提供者 url。重定向 URI 必须与客户端的 URis 注册相匹配。您可以在授权请求中发送任何客户端允许的范围。
我希望能够从单个网络应用程序调用不同的应用程序寄存器。我不知道该怎么做。起初我以为我可以向我的服务提供商添加多个 MsalAuthentications,而不是调用一个特定的。我无法让它工作,所以现在我想知道是否可以更改我在开始时添加的 MsalAuthentication 的选项。
这是我添加 MSAL 身份验证的方式:
builder.Services.AddMsalAuthentication(options =>
{
var authentication = options.ProviderOptions.Authentication;
authentication.Authority = FakeADTenant.TenantAddress;
authentication.ClientId = FakeADTenant.AppId;
authentication.ValidateAuthority = true;
options.ProviderOptions.DefaultAccessTokenScopes.Add(FakeADTenant.TokenScope);
});
在另一端,当点击登录按钮时,我正在使用此页面登录:
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />
@code{
[Parameter] public string Action { get; set; }
}
我想我可以在调用 RemoteAuthenticatorView 之前更改代码中的选项。我只想更改 authentication.Authority、authentication.ClientId 和 options.ProviderOptions.DefaultAccessTokenScopes。
不,作为任何 OAuth 提供者,您不能更改 clientId,The Authority 是 OAuth 提供者 url。重定向 URI 必须与客户端的 URis 注册相匹配。您可以在授权请求中发送任何客户端允许的范围。