keycloak identity Provider gitlub

keycloak支持使用外部认证中心进行认证。

下图就是接入了gitlub认证的keycloak登录页面(类似于好多网站都有的使用Sina微博账号登录、使用QQ账号登录)。


点击GitLub按钮,将会进入GitLub的登录页面,使用Gitlub账号登录GitLub后,会进入确认授权页面,如:



 

确认授权后,回跳至keycloak页面,

如果是首次登录,会进入完善信息页面,如:


说明:

1、填写的 email  如果与keycloak-realm中已存在的用户的email相同,

会给出两种处理方式让用户选择,

一是返回修改填写的email。

二是绑定到该email相同的账号。

如果选择方式二,需要进一步提供拥有相同email账号的密码。

2、与 email 处理方式相同,

如果填写的username与keycloak-realm已存在的账号相同,

也会给出两种处理方式让用户选择。

一是返回修改填写的username。

二是绑定到该username相同的账号。

如果选择方式二,需要进一步提供拥有相同email账号的密码。


如果选择绑定到已有账号(Add to existing account)

 
 

如果非首次登录,或者首次登录并完善账号信息后,会转向初始访问的服务页面。

登录完成后,在用户详情页面,

可通过Indentity Provider Links查看用户与Indentity Provider的绑定关系。



 
 

整个流程如下:


 

认证请求流转图:



As you may notice,

at the end of the authentication process Keycloak will always issue its own token to client applications. What this means is that client applications are completely decoupled【解耦】 from external identity providers. They don’t need to know which protocol (eg.: SAML, OpenID Connect, OAuth, etc) was used or how the user’s identity was validated. They only need to know about Keycloak. 

配置步骤:

1、以管理员身份登录keycloak,

2、选择要操作的Realm,点击菜单:Configure——Identity Providers

3、根据需要选择合适的Provider,如:Github



 

4、进入Add Identity Provider配置页面,记录下自动生成的Redirect URI。

 

 

5、登录Github:https://github.com/  ,展开页面右上角下拉菜单,点击Settings。



 

6、在个人信息Setting页面,点击左侧菜单中的 Developer Settings。

7、在 Developer Settings 页面,点击左侧菜单中的 OAuth Apps。

8、在OAuth Apps页面,点击【New OAuth App】按钮,进入新建OAuth App 页面。

      将第四步记录下的Redirect URI填写到Authorization callback URL处。

 

9、点击 Register Application,完成OAuth APP的新建。

10、在新建的OAuth APP详情页面,记录下ClientId和Client Secret。

11、将记录下ClientId和Client Secret填写到第四步Add Identity Provider页面的CLientId和Client Secret处。

12、完成keycloak 与 github的对接,可以使用 github 登录 keycloak了。

 更多信息参考:http://www.keycloak.org/docs/latest/server_admin/index.html#_identity_broker


 

猜你喜欢

转载自huangqiqing123.iteye.com/blog/2414400