Keycloak 从客户端升级

发布于 2025-01-12 21:29:19 字数 786 浏览 4 评论 0原文

Keycloak 此处的文档表示您需要添加 ACR请求中的声明,以便将身份验证提升到更高级别。但是,这是如何从 keycloak.js 客户端库或 keycloak-js npm 客户端库完成的呢?

那么基本上,如何传递以下声明查询参数?

https://{DOMAIN}/realms/{REALMNAME}/protocol/openid-connect/auth?client_id={CLIENT-ID}&redirect_uri={REDIRECT-URI}&scope=openid&response_type=code&response_mode=query&nonce=exg16fxdjcu&claims=%7B%22id_token%22%3A%7B%22acr%22%3A%7B%22essential%22%3Atrue%2C%22values%22%3A%5B%22gold%22%5D%7D%7D%7D

声明的格式如下所示,如文档中所示:

claims= {
        "id_token": {
            "acr": {
                "essential": true,
                "values": ["gold"]
            }
        }
    }

The Keycloak documentation here says you need to add ACR with claims in the request in order to do authentication step up to a higher level. But how is this accomplished from either the keycloak.js client library, or the keycloak-js npm client library?

So basically, how do you get the following claims query param to be passed?

https://{DOMAIN}/realms/{REALMNAME}/protocol/openid-connect/auth?client_id={CLIENT-ID}&redirect_uri={REDIRECT-URI}&scope=openid&response_type=code&response_mode=query&nonce=exg16fxdjcu&claims=%7B%22id_token%22%3A%7B%22acr%22%3A%7B%22essential%22%3Atrue%2C%22values%22%3A%5B%22gold%22%5D%7D%7D%7D

The format of the claims is like this as seen in the documentation:

claims= {
        "id_token": {
            "acr": {
                "essential": true,
                "values": ["gold"]
            }
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安静 2025-01-19 21:29:19

这是我突然想到的,但我认为这应该可以做到。

const keycloak = Keycloak({
  url: {DOMAIN},
  realm: {REALMNAME},
  clientId: {CLIENT-ID}
});

keycloak.login({
    ... your login options
    acr: { values: ["silver", "gold"], essential: true } 
})

适配器将采用 acr 选项并将其应用于 claims.id_token

Doing this off the top of my head, but I think this should do it.

const keycloak = Keycloak({
  url: {DOMAIN},
  realm: {REALMNAME},
  clientId: {CLIENT-ID}
});

keycloak.login({
    ... your login options
    acr: { values: ["silver", "gold"], essential: true } 
})

The adapter will take the acr option and apply it to claims.id_token

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文