假设我们正在使用this OpenID Connect sample。
这是OpenID的添加方式:
services.AddAuthentication(options => {
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(options => {
options.LoginPath = "/Account/Login/";
})
.AddOpenIdConnect(options =>
{
options.ClientId = ONELOGIN_OPENID_CONNECT_CLIENT_ID;
options.ClientSecret = ONELOGIN_OPENID_CONNECT_CLIENT_SECRET;
// For EU Authority use: "https://openid-connect-eu.onelogin.com/oidc";
options.Authority = "https://openid-connect.onelogin.com/oidc";
options.ResponseType = "code";
options.GetClaimsFromUserInfoEndpoint = true;
}
);
如何使用Bearer
身份验证方案代替cookie
?我想处理用户信息并将其存储在数据库中。