1

我已经成功地创建了我的第一个 OmniAuth 策略并将其打包为一个 gem。我将此添加到 GitLab 中的 Gemfile 并运行bundle install --path vendor/bundle --no-deployment,它安装了 gem。

接下来,我通过复制我们为 GitHub 拥有的部分并用我们自己的值完成它来更新 gitlab.yml 文件。

按照https://github.com/gitlabhq/gitlabhq/blob/5-3-stable/doc/install/installation.md上的 GitLab 参考说明的指示, 然后我将两个图像文件添加到vendor/assets/images/authbuttons目录中,格式均为小写“strategyname_32.png”和“strategyname_64.png”。

最后,我重新启动了 GitLab,在登录页面上,我现在看到了一个用于我们新提供程序的按钮(它有效,是的!)但是我上传的图像没有用于按钮,而是使用了一个基本的灰色按钮。

我在任何日志中都找不到任何内容,表明它无法找到图像文件,并且我尝试使用各种情况重命名文件,因为这是在 Ubuntu 系统上。我也执行了 a rake assets:precompile RAILS_ENV=production,但这似乎并没有什么不同。

我是否遗漏了一些东西来让这个提供者用我们的图像而不是登录页面上的基本 HTML 按钮来表示?我没有在说明中看到我遗漏的任何步骤。

4

1 回答 1

1

事实证明,这是“设计使然”,其他提供程序作为 HTML 按钮加载,并且不使用vendor/assets/images/authbuttons安装说明中提到的放置在路径中的图形。default_providers() 这是因为只有功能内列出的提供者才app/helpers/oauth_helper.rb使用vendor/assets/images/authbuttons目录中的图像显示在登录页面上。

因此,为了让我成功使用我的自定义omniauth 提供程序并在GitLab 登录页面上有一个用于登录链接的图形元素,我执行了以下操作:

  • 停止 GitLabsudo service gitlab stop
  • 将我的两个图形放在vendor/assets/images/authbuttons目录中
  • 将我的提供程序添加为文件default_providers()功能中的默认提供程序之一app/helpers/oauth_helper.rb
  • config/gitlab.ymlclient_idand中为我的提供者添加了一个部分client_secret
  • 将我的omniauth策略添加到Gemfile文件中
  • 使用从 GitLab 根目录安装 gemsudo -u git -H bundle install --without development test postgres --path vendor/bundle --no-deploy
  • 使用从 GitLab 根目录预编译资产sudo -u git -H rake assets:precompile RAILS_ENV=production
  • 启动 GitLabsudo service gitlab start
于 2013-07-25T21:34:30.840 回答