OpenID 连接 AzureAD redirect_uri 为空

问题描述 投票:0回答:1

我在 httpd 反向代理后面有一个 .net .6 Linux 应用程序。

当重定向到 azure 进行身份验证时,我收到以下错误

AADSTS90102:“redirect_uri”值必须是有效的绝对 URI。

上面的网址是

https://login.microsoftonline.com/XXX/oauth2/v2.0/authorize?client_id=YYY&redirect_uri=http%3A%2F%2F%28null%29%2Fsignin-oidc&response_type=id_token&scope=openid%20profile&response_mode=form_post&nonce= zzz&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.17.0.0

我认为这里最大的收获是redirect_uri=http%3A%2F%2F%28null%29%2Fsignin-oidc

我的 Program.cs 中有以下所有内容

// Add services to the container.
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"));

builder.Services.AddAuthorization(options =>
{
    // By default, all incoming requests will be authorized according to the default policy.
    options.FallbackPolicy = options.DefaultPolicy;
});
builder.Services.AddRazorPages()
    .AddMicrosoftIdentityUI();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseForwardedHeaders();

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseSession();
app.UseAuthentication();
app.UseAuthorization();

app.MapRazorPages();
app.MapControllers();

app.Run();

我的 appsettings.json 是


  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "mydomain.com",
    "TenantId": "xxx",
    "ClientId": "yyy",
    "CallbackPath": "/signin-oidc"
}

我的企业应用程序具有以下 URL

https://somesite-dev.mydomain.com/signin-oidc

我的httpd配置有

 ServerName somesite-dev.mydomain.com

  ProxyRequests Off
  RequestHeader set Host %{HOST}s
  RequestHeader set X-Real-IP %{REMOTE_ADDR}s
  RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
  RequestHeader set X-Forwarded-Host %{SERVER_NAME}s
  ProxyPass / http://1.2.3.4:8888/
  ProxyPassReverse / http://1.2.3.4:8888/

出于安全原因,xxx、yyy、zzz、somesite-dev 和 mydomain.com 已更改。

尽管如此,为什么我的重定向 URI 为空?这在 VS 调试器中工作得很好

我已从企业应用程序中删除了其他条目,仅包含 服务器名称 somesite-dev.mydomain.com

.net azure azure-active-directory openid-connect httpd.conf
1个回答
0
投票

您必须使用 HTTPS 作为重定向 URI,否则 cookie(由于 Samesite 属性)将被阻止,一切都会中断。

也许删除,因为这通常被设置为默认值。

"CallbackPath": "/signin-oidc"

r 将其中的 URL 设置为绝对 URL,例如:

"CallbackPath": "https://somesite-dev.mydomain.com/signin-oidc"
© www.soinside.com 2019 - 2024. All rights reserved.