0

当某些管理员客户端的某些管理员用户能够创建用户并获取他们的访问令牌以用于其他客户端时,我正在尝试启用流程。

我有带有令牌交换的 KeyCloak 设置以及启用和配置了细粒度 authz的客户端。我可以通过 REST api 登录我的管理员用户,然后交换令牌。但是当我指定观众时,我得到了错误。

这个返回令牌,但我需要另一个客户/观众的令牌。

http -f POST https://my-keycloak-server.com/auth/admin/realms/my-realm/protocol/openid-connect/token grant_type=urn:ietf:params:oauth:grant-type:token-exchange requested_subject=1a147915-53fe-454d-906a-186fecfa6974 client_id=api-admin client_secret=23a4ecbe-a9e8-448c-b36a-a45fa1082e6e subject_token=eyJhbGeiOiJSUzI1NiIs...... 

这个失败并出现错误。

http -f POST https://my-keycloak-server.com/auth/admin/realms/my-realm/protocol/openid-connect/token grant_type=urn:ietf:params:oauth:grant-type:token-exchange requested_subject=1a147915-53fe-454d-906a-186fecfa6974 client_id=api-admin client_secret=23a4ecbe-a9e8-448c-b36a-a45fa1082e6e subject_token=eyJhbGeiOiJSUzI1NiIs...... audience=my-another-client
{
    "error": "access_denied", 
    "error_description": "Client not allowed to exchange"
}

所以我尝试为目标受众客户端设置细粒度的身份验证(在选项卡中启用它,然后尝试为我的管理员用户添加策略以便能够交换令牌)但是当我想添加允许我的管理员用户执行令牌的策略时交换我卡在 UI 错误上。

当 Keycloak 正在寻找名称 colisions 时,键入策略名称时我得到 404。在这种情况下,Afaik 404 不应阻止表单发布,因为它没有名称冲突。相反,我立即被错误重定向。

https://my-keycloak-server.com/auth/admin/realms/my-realm/clients/1bafa9a4-f7e2-422c-9188-58ea95db32ef/authz/resource-server/policy/search?name=some-name

归根结底,我无法在 Keycloak 中添加任何策略。一直以来,表单验证都以找不到 404 策略名称导致的崩溃而告终。

我正在使用 dockerized keycloak 10.0.0

有任何想法吗?

4

1 回答 1

1

我通过实时编辑 Angular JS UI 脚本函数破解了它,该函数在第 2403 行执行验证。

this.checkNameAvailability = function (onSuccess) {
            if (!$scope.policy.name || $scope.policy.name.trim().length == 0) {
                return;
            }
            ResourceServerPolicy.search({
                realm: $route.current.params.realm,
                client: client.id,
                name: $scope.policy.name
            }, function(data) {
                if (data && data.id && data.id != $scope.policy.id) {
                    Notifications.error("Name already in use by another policy or permission, please choose another one.");
                } else {
                    onSuccess();
                }
            });
}

this.checkNameAvailability = function (onSuccess) {
    onSuccess();
}

最终成功添加了政策。看起来仍然是 UI 错误。

于 2020-05-21T14:17:11.440 回答