1 回答

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
客戶端應(yīng)用程序負(fù)責(zé)在連接 openid 中間件時(shí)設(shè)置 OpenIdConnect 選項(xiàng)。選項(xiàng)對(duì)象的屬性之一稱為“ClaimActions”。這些聲明操作允許客戶端連接自定義映射屬性。
以下是我添加到客戶端啟動(dòng)類中的代碼,以使該代碼適用于一組自動(dòng)序列化的聲明。
services.AddAuthentication(options =>
{
? ?options.DefaultScheme = "Cookies";
? ?options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
{? ? ? ? ? ? ? ? ? ??
? ? options.SignInScheme = "Cookies";
? ? options.Authority = "http://localhost:5000";
? ? options.RequireHttpsMetadata = false;
? ? options.ClientId = "mvc";
? ? options.ClientSecret = "secret";
? ? options.ResponseType = "code id_token";
? ? options.SaveTokens = true;
? ? options.GetClaimsFromUserInfoEndpoint = true;
? ? options.Scope.Add("athlete.full");
? ? options.Scope.Add("rights");
? ? options.Scope.Add("email");
? ? options.Scope.Add("address");
? ? options.Scope.Add("phone");
? ? options.Scope.Add("offline_access");
? ? // These are what allowed the claims to be serialized for front-end consumption.
? ? options.ClaimActions.MapJsonKey(JwtClaimTypes.WebSite, "website");
? ? options.ClaimActions.MapJsonKey(JwtClaimTypes.Gender, "gender");
? ? options.ClaimActions.MapJsonKey(JwtClaimTypes.BirthDate, "birthdate");
});
- 1 回答
- 0 關(guān)注
- 112 瀏覽
添加回答
舉報(bào)