Keycloak-gatekeeper:"aud"声明和"client_id"不匹配 [英] Keycloak-gatekeeper: 'aud' claim and 'client_id' do not match

查看:409
本文介绍了Keycloak-gatekeeper:"aud"声明和"client_id"不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置aud声明以避免以下错误的正确方法是什么?

What is the correct way to set the aud claim to avoid the error below?

unable to verify the id token   {"error": "oidc: JWT claims invalid: invalid claims, 'aud' claim and 'client_id' do not match, aud=account, client_id=webapp"}

我通过硬编码aud声称与我的client_id相同来解决此错误消息.有什么更好的方法吗?

I kinda worked around this error message by hardcoding aud claim to be the same as my client_id. Is there any better way?

这是我的docker-compose.yml:

version: '3'
services:
  keycloak-proxy:
    image: "keycloak/keycloak-gatekeeper"
    environment:
     - PROXY_LISTEN=0.0.0.0:3000
     - PROXY_DISCOVERY_URL=http://keycloak.example.com:8181/auth/realms/realmcom
     - PROXY_CLIENT_ID=webapp
     - PROXY_CLIENT_SECRET=0b57186c-e939-48ff-aa17-cfd3e361f65e
     - PROXY_UPSTREAM_URL=http://test-server:8000
    ports:
      - "8282:3000"
    command:
      - "--verbose"
      - "--enable-refresh-tokens=true"
      - "--enable-default-deny=true"
      - "--resources=uri=/*"
      - "--enable-session-cookies=true"
      - "--encryption-key=AgXa7xRcoClDEU0ZDSH4X0XhL5Qy2Z2j"
  test-server:
    image: "test-server"

推荐答案

在最新的4.3.6版密钥斗篷中,客户端ID显然不再自动添加到访问令牌的受众字段"aud"中. 因此,即使登录成功,客户端也会拒绝用户. 要解决此问题,您需要为客户配置受众群体(比较文档[2]).

With recent keycloak version 4.6.0 the client id is apparently no longer automatically added to the audience field 'aud' of the access token. Therefore even though the login succeeds the client rejects the user. To fix this you need to configure the audience for your clients (compare doc [2]).

  • 添加领域或配置现有域
  • 添加客户端我的应用"或使用现有的
  • 转到新添加的客户范围"菜单[1]
查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆