简体   繁体   English

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

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

We use Keycloak with Google IDP to authenticate.我们使用 Keycloak 和 Google IDP 进行身份验证。 When a user log in using Google, I want to hook into the flow to add some roles for that user session.当用户使用 Google 登录时,我想加入流程以为该用户 session 添加一些角色。

What should I do?我应该怎么办? I have tried creating to custom Authenticator but not sure this is the possible or best practice.我尝试创建自定义身份验证器,但不确定这是可能的还是最佳实践。

Please help!请帮忙! Thanks!谢谢!

When a user log in using google, I want to hook into the flow to add some roles for that user session.当用户使用 google 登录时,我想加入流程以为该用户 session 添加一些角色。

Not sure what you do mean by roles to the user session.不确定您对用户 session 的角色意味着什么。 However, if you mean add roles to the user yes you can do that out of the box for instance:但是,如果您的意思是向用户添加角色,是的,您可以开箱即用地执行此操作,例如:

  • Go to your Realm; Go 到您的 Realm;
  • Select Identity Providers; Select 身份提供者;
  • Select you google IDP; Select 你谷歌 IDP;
  • Switch to the tab Mappers;切换到选项卡映射器;
  • Click on [Create]点击【创建】
  • Select as a Mapper Type : Hardcoded Role Select 作为Mapper TypeHardcoded Role
  • Select the Role; Select 角色;
  • Click on [save].点击[保存]。

在此处输入图像描述

Here is the list of Mapper Types available for the Google IDP:以下是可用于 Google IDP 的映射器类型列表:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在keycloak中的oidc身份提供者中使用map azure object_id? - How to map azure object_id in oidc identity provider in keycloak? 使用keycloak作为身份代理首次登录时,将特定于客户端的角色自动从IDP添加到IDP的用户数据中 - Add client-specific roles automatically to userdata from IDP on first login with keycloak as an identity broker Keycloak OIDC 身份提供程序内部服务器错误 - Keycloak OIDC Identity Provider internal server error 如何正确添加keycloak用户迁移提供程序? - How do you add keycloak user migration provider properly? 身份验证后以编程方式添加角色 - Programmatically add roles after authentication 如何使用 OIDC 和我自己的身份提供者登录 Google 工作区 - How to login into Google workspace using OIDC with my own identity provider Keycloak 自定义用户联盟和身份提供者工作顺序 - Keycloak Custom User Federation and Identity Provider Working Order 如何将 Identity server 4.0 添加为外部提供者? - How do you add Identity server 4.0 as an external provider? 独立 Keycloak 作为身份提供者在登录期间导致错误 - Standalone Keycloak as Identity-Provider causing error during login 使用Google作为身份提供商使用Salesforce进行Api身份验证 - Api Authentication with Salesforce using Google as an Identity Provider
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM