使用oidc客户端的身份服务器4中的post_logout_redirect_uri为null

时间:2020-10-06 12:40:34

标签: identityserver4

我使用的身份服务器4的最小配置是将客户端存储在内存中(JavaScript客户端)。 然后使用oidc-client.js连接到ID4服务器,我将遵循ID4提供的示例,该示例可用于注销。

但是在我们现有项目和注销中使用的同一库无法从logoutId填充'PostLogoutRedirectUri'和'clientName',因此,注销后我们无法重定向回原始应用程序的页面。

 var config = {
                    authority: "https://localhost:44374",
                    client_id: "JsClient",
                    redirect_uri: "https://localhost/<myexistingapp>/callback.html",
                    response_type: "code",
                    scope: "openid profile Api.read Api.write",
                    post_logout_redirect_uri: "https://localhost/<myexistingapp>/Home/Index",
                };

                var mgr = new Oidc.UserManager(config);

及以下点击按钮的方法

   externalSignOut = function () {
                        mgr.signoutRedirect();
                    }

唯一的区别是上述方法是在jquery的document ready方法下定义的 [$(document).ready((function(){...] 与正在运行的示例应用程序相比。

因此,在登录后的现有应用程序中,我们将重定向到MVC路由,并再次注销以从启动登录的位置返回到初始页面,因此我们可以准备用户管理器对象。 然后调用退出功能。

尽管这里它填充了loginId,但是当它抽象出客户端名称的信息时内部代码却填充了内部代码,而PostLogoutRedirectUri为null ...不确定这些信息在哪里丢失。

**我想念的还是需要做的是什么... **

客户端定义为

 new Client
                {
                    ClientId = "JsClient", 
                    ClientName = "JavaScript Client", 
                    AllowedGrantTypes = GrantTypes.Code,
                    RequireClientSecret = false,

                    RedirectUris =           { "https://localhost/<myexistingapp>/callback.html"}, 
                    PostLogoutRedirectUris = { "https://localhost/<myexistingapp>/Home/Index" }, 
                    AllowedCorsOrigins =     { "https://localhost" }, 
                    AllowedScopes =
                    {
                        IdentityServerConstants.StandardScopes.OpenId,
                        IdentityServerConstants.StandardScopes.Profile,
                        IdentityServerConstants.StandardScopes.Email,
                        "Api.read", 
                        "Api.write" 
                    },

                },

0 个答案:

没有答案