我有一个使用IdentityServer4的自定义 Open Id Connect 服务器。此 SSO 服务器具有用于非标准 Open Id Connect 操作的自定义端点。
为了使用这个操作,我需要在客户端应用程序的请求中创建一个状态参数。客户端应用程序是带有 blazor 服务器端的 dotnet core 3.0 预览应用程序。
我正在使用以下内容注册 SSO 提供程序:
services.AddAuthentication(options => {
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = "oidc";
})
.AddCookie()
.AddOpenIdConnect("oidc", options => {
options.ClientId = oidcClientId;
options.ClientSecret = "secret";
options.Authority = "https://test.org";
options.ResponseType = "code id_token";
options.Scope.Clear();
options.Scope.Add("openid");
options.Scope.Add("extra");
options.GetClaimsFromUserInfoEndpoint = true;
options.SaveTokens = true;
options.RequireHttpsMetadata = false;
});
Run Code Online (Sandbox Code Playgroud)
基本登录/注销流程按预期工作,没有任何问题。
我为使用自定义 SSO 功能而生成的自定义链接如下所示(razor):
<a href=@($"https://test.org/custom/change-organization/{organization.OrganizationCode}?client_id=local-data-manager&redirect_uri=http://localhost:5000/signin-oidc&response_type=code id_token&scope=openid custom profile&nonce={GenerateNonce()}&state={GenerateState()}")>@organization.Name</a>
Run Code Online (Sandbox Code Playgroud)
使用定义的方法:
private string GenerateNonce()
{
string nonce …Run Code Online (Sandbox Code Playgroud)