我有 .net 核心 mvc 应用程序。我已使用 Azure AD 为我的 Web 应用实施 OAuth 身份验证。
从 localhost 它按预期运行良好,但从 Azure WebApp 成功 OAuth 身份验证后,它无法重定向到路径。
仅供参考,我正在通过 AppGateway 访问该应用程序
我正在使用以下代码块进行 OAuth 身份验证。
Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));
services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
appsettings.json:
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
"ClientId": "567f20e2-eb4f-4a1b-8fe6-ff1d76be8ec0",
"TenantId": "ea80952e-xxxx-xxxx-xxxx-5457852b0f7e",
},
我尝试在 Azure 应用程序注册边栏选项卡中定义重定向 url,但定义的值不是从应用程序中选取的。
Azure App registration redirect url
谁能帮我解决这个问题。
附上截图供您参考。 Screenshot of error response after successful authentication