How to integrate Cloud Foundry with Gitlab
by Gastón Ramos
This article explains how to use gitlab and login against a cloud foundry authorization server.
Basically you will need 3 components:
In a real world probably you already has a uaa server installed, but for the purpose of this article let’s start cloning and installing a fresh uaa;
git clone email@example.com:cloudfoundry/uaa.git cd uaa mvn install
Ok. with this we have the uaa server installed so now we will install gitlab, I’m not going to explain the whole installation
process that you can find in the gitlabhq readme, for the purpose of this article you only needs to install the required gems and that’s all.
git clone firstname.lastname@example.org:gitlabhq/gitlabhq.git cd gitlabhq cp config/database.yml.mysql config/database.yml cp config/gitlab.yml.example config/gitlab.yml bundle install
Omniauth uaa strategy installation
Now we have a basic installation of gitlab, but we need to add the omniauth-uaa-oauth2 strategy for omniauth to be able to login against uaa.
First we need to clone the omniauth-uaa-oauth2 and install it:
git clone email@example.com:cloudfoundry/omniauth-uaa-oauth2.git bundle install bundle exec gem build omniauth-uaa-oauth2.gemspec gem install omniauth-uaa-oauth2-*.gem
Enable omniauth and cloudfoundry strategy
Now let’s go back to the gitlabhq dir
and add this 3 lines into the Gemfile:
gem 'cf-uaa-lib', '1.3.10' gem 'omniauth-uaa-oauth2
And then enable oauth in the gitlab.yml, basically we should change the omniauth enabled to true and add the cloudfoundry to the omniauth providers, so the gitlab.yml config file should look like this:
Now that we have all the required components installed and cofigured we should ensure that uaa and gitlab are up (“mvn tomcat:run” for uaa and “rails s” for gitlab) and then open a browser and go to http://localhost:3000 and as you can see in the image you should see the gitlab login page with a “Sign in with cloudfoundry” button in it.
Update: I’ve made a video to show the login screen