直接裸体冒充

问题描述

我在执行这些步骤时遇到问题,记录在 Securing Applications and Services Guide 中。 stackoverflow 中的 This thread 显示一个不起作用的选项。有人可以指出解决此问题以允许裸体冒充所需的步骤吗?

附加图片中的领域/客户端/策略/用户详细信息。 enter image description here

查询

curl -k -X POST
–header ‘Content-Type: application/x-www-form-urlencoded’
–data-urlencode “client_id=starting-client”
–data-urlencode “client_secret=.....”
–data-urlencode “grant_type=urn:ietf:params:oauth:grant-type:token-exchange”
–data-urlencode “requested_subject=target-user”
https://localhost:8543/auth/realms/target_realm/protocol/openid-connect/token

回复

{“error”:“access_denied”,“error_description”:“Client not allowed to exchange”}

服务器日志:

22:40:08,396 WARN [org.keycloak.events] (default task-149) type=TOKEN_EXCHANGE_ERROR,realmId=target_realm,clientId=starting-client,userId=null,ipAddress=172.17.0.1,error=not_allowed,reason=‘client not allowed to impersonate’,auth_method=token_exchange,grant_type=urn:ietf:params:oauth:grant-type:token-exchange,requested_subject=target-user,client_auth_method=client-secret

解决方法

这是 Securing Applications and Services Guide 中的文档的问题。不是为“用户模拟”范围添加客户端策略,而是必须为“模拟”范围添加策略。更改完成后,它就开始起作用了。