Keycloak:如何连接到 Google 身份提供者以编程方式添加角色

Keycloak: How to hook into Google Identity Provider to add roles programmatically

我们使用带有 Google IDP 的 Keycloak 进行身份验证。当用户使用 Google 登录时,我想挂接到流程中为该用户会话添加一些角色。

我该怎么办?我已尝试创建自定义 Authenticator,但不确定这是可能的还是最佳做法。

请帮忙!谢谢!

When a user log in using google, I want to hook into the flow to add some roles for that user session.

不确定用户会话的角色是什么意思。但是,如果您的意思是向用户添加角色,是的,您可以开箱即用:

  • 进入你的领域;
  • Select 身份提供商;
  • Select你google国内流离失所者;
  • 切换到映射器选项卡;
  • 点击[创建]
  • Select 作为 Mapper Type : Hardcoded Role
  • Select角色;
  • 点击[保存]。

这是可用于 Google IDP 的映射器类型列表: