c# - 添加到服务提供者后能否更改Msal Authentication中的Authority、ClientId、DefaultAccessTokenScopes

标签 c# authentication azure-active-directory blazor azure-ad-msal

我希望能够从单个 Web 应用程序调用不同的应用程序寄存器。我不知道该怎么做。起初,我认为我可以向我的服务提供者添加多个 MsalAuthentication,而不是调用特定的服务提供者。我无法让它工作,所以现在我想知道是否可以更改我在开始时添加的 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,权威是 OAuth 提供商 url。重定向 URI 必须与为客户端注册的 URI 匹配。您可以在授权请求中发送任何客户端允许的范围。

关于c# - 添加到服务提供者后能否更改Msal Authentication中的Authority、ClientId、DefaultAccessTokenScopes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63137614/

相关文章:

node.js - Azure Web 应用程序 + Node.js + Azure AD = 错误 431

azure - Xamarin.Forms Azure 移动应用服务离线同步,无需在 Azure 上托管 Web Api

c# - 重复遍历列表

c# - MVC : How do I decode code to JS that was encoded in c# using JavaScriptSerializer

c# - 禁用基于绑定(bind)值 WPF 的 ListBox 项的选择

c# - 使用 Cmd Prompt 将 DateTime 变量传递给控制台应用程序

swift - 登录警报 swift 2.0 后打开一个新的 View Controller

javascript - 通过 cURL 登录到 Javascript 页面?

java - ReSTLet - 在身份 validator 中使用 URI 模板变量

azure - 如何从 Azure AD 查找重复用户?