gitlab实现对接IdentityServer4的authorization_code模式流程

1.修改gitlab相关配置,将第三方登录入口打开并配置授权方,模式为授权码模式并重启

基于docker容器:修改config/gitlab.yml文件:

2.在认证中心新建客户

3.认证中心根据oidc规范设置授权后用户信息字段

 

认证中心:

 

4.问题

4.1 认证中心redirectUris

认证中心目前无法设置授权码模式下的回调url,所以有两种方案可修改:

① 先将授权模式设置为implicit,将回调url设置完毕后,改回code模式,此方法验证可行

② 直接通过修改数据库表字段方式修改回调url

4.2 认证中心-颁发者问题

问题:

原因:gitlab验证了颁发者

颁发者的属性应与提供者的url完全匹配,不然授权第一步将不会通过

4.3 认证中心授权成功后gitlab账号创建问题

授权成功后,gitlab验证用户信息的字段有2个,sub与email,这两个缺一不可,如果你的preferred_username为空,gitlab会自动设置你的账号为你的邮箱前缀,比如你的账号是zhangsan@zhongruigroup.com,那账号就是 zhangsan ;所以说如果要跟我们用户中心一致的话需要将preferred_username作为我们的账号返回。

参考:

https://docs.gitlab.com/ee/administration/auth/oidc.html

https://docs.openshift.com/enterprise/3.2/install_config/configuring_authentication.html#OpenID

https://identityserver4.readthedocs.io/en/aspnetcore2/endpoints/token.html

https://dev.mendeley.com/reference/topics/authorization_auth_code.html

https://hub.fastgit.org/omniauth_openid_connect#additional-configuration-notes

原文地址:https://www.cnblogs.com/walt/p/14694083.html