ruby - How pass oAuth2 server URL in config/gitlab.yml under providers -
we have setup gitlab , working well. have our own oauth2 server we'd connect to, account in our oauth2 server can have access gitlab.
we've installed omniauth-oauth2 (https://rubygems.org/gems/omniauth-oauth2) , have enabled in gitlab.yml this:
omniauth: enabled: true providers: - { name: 'oauth2' }
when restart gitlab see oauth2 button on login page, url our oauth2 server wrong, , haven't set out app_id , app_secret.
my question is: how pass params , related data app_id, app_secret , oauth2 server url via settings file. we've tried number of things far, haven't gotten far.
notes:
- i've never used ruby before week. learned lot far!
- we've attempted set additional args args: { url: 'url-to-our-oauth2-server' }
- i believe need create own strategy file, plan on doing based on supplied omniauth-oauth2 strategy file
to use our own oauth server, had write our own strategy implements omniauth, , import via gemfile. oauth urls within strategy. placed our oauth keys in /home/git/gitlab/config/initializers/devices.rb file before last 'end' statement:
end config.omniauth :strategy_name, "{client_id_goes_here}", "{client_key_goes_here}" end
our strategy looks this, replacing strategy_name strategy name, , replacing site, authorize_url , token_url own urls:
require 'omniauth-oauth2' module omniauth module strategies class strategy_name < omniauth::strategies::oauth2 option :client_options, { :site => 'https://authserve.mydomain.com', :authorize_url => 'https://authserve.mydomain.com/oauth/authorize', :token_url => '/oauth/access_token' } def request_phase super end def authorize_params super.tap |params| %w[scope client_options].each |v| if request.params[v] params[v.to_sym] = request.params[v] end end end end uid { raw_info['id'].to_s } info { :email => raw_info['email'], :name => raw_info['name'], :nickname => raw_info['username'] } end {:raw_info => raw_info} end def raw_info @raw_info ||= access_token.get("/v1/users?access_token=#{access_token.token}").parsed end end end end
Comments
Post a Comment