部署测试环境
为了方便演示,我用docker快速搭建一个gitlab环境
docker run -itd -p 80:80 --privileged=true --name gitlab-test gitlab/gitlab-ce
启动较慢,稍等片刻后访问
账号默认是root,密码
grep 'Password:' /etc/gitlab/initial_root_password
配置微信开放平台
地址:https://open.weixin.qq.com/
申请好AppID和AppSecret
wxb652751f377ccc7e
d52fd910e3984a0c0f69a285c8ac7c4b
配置好“授权回调域”
配置gitlab的微信登录
gitlab主要使用的是ruby编程语言写的,所以这里用到了gem和bundle命令
- gem是Ruby的一个包管理器
- bundle是一个 Ruby 的依赖管理工具
修改源
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems
添加依赖
cd /opt/gitlab/embedded/service/gitlab-rails
vi Gemfile
添加内容:
gem ‘omniauth-wechat-oauth2’, ‘0.2.2’
bundle config set frozen false
bundle install
vi /etc/gitlab/gitlab.rb
external_url 'http://10.0.1.104:9980'
gitlab_rails['omniauth_providers'] = [
{
name: "wechat",
label: "微信",
app_id: "YOUR_APP_ID",
app_secret: "YOUR_APP_SECRET"
}
]
重新加载配置
gitlab-ctl reconfigure
验证
再次访问登录页面,此时已经出现“微信”扫码登录按钮
点击后,回跳转到微信扫码页面
扫码确认,成功进入gitlab
大功告成!
如有其他问题可联系作者:
手机、微信:15385125253
QQ:987319557
公司名称:开源互联网安全技术有限公司
原创作者:谢少评
原创不易,一分也是爱:
微信:
支付宝: