我的應用程式中有 AAD 身份驗證。不幸的是,當未登錄的用戶請求任何資源時,我得到回應標頭:
WWW-Authenticate: Bearer
但我應該得到標題的回應:
WWW-Authenticate: Bearer authorization-uri=https://example.com
有沒有辦法實作這一目標?
uj5u.com熱心網友回復:
您可以更改JwtBearerOptions.Challenge屬性:
services.AddAuthentication()
// If use AddJwtBearer
.AddJwtBearer(opt =>
{
opt.Challenge = "Bearer authorization-uri=https://example.com";
})
// If use Microsoft.Identity.Web
.AddMicrosoftIdentityWebApi(configureJwtBearerOptions: opt =>
{
opt.Challenge = "Bearer authorization-uri=https://example.com";
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/338727.html
