1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'omniauth-oauth2'
8 class JoshId < OmniAuth::Strategies::OAuth2
10 args [:client_id, :client_secret, :custom_provider_url]
12 option :custom_provider_url, ''
14 uid { raw_info['id'] }
16 option :client_options, {}
20 :first_name => raw_info['info']['first_name'],
21 :last_name => raw_info['info']['last_name'],
22 :email => raw_info['info']['email'],
23 :identity_url => raw_info['info']['identity_url'],
24 :username => raw_info['info']['username'],
30 'raw_info' => raw_info
35 options.authorize_params[:auth_provider] = request.params['auth_provider']
40 options.client_options[:site] = options[:custom_provider_url]
41 options.client_options[:authorize_url] = "#{options[:custom_provider_url]}/auth/josh_id/authorize"
42 options.client_options[:access_token_url] = "#{options[:custom_provider_url]}/auth/josh_id/access_token"
43 if Rails.configuration.sso_insecure
44 options.client_options[:ssl] = {verify_mode: OpenSSL::SSL::VERIFY_NONE}
46 ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
50 full_host + script_name + callback_path + "?return_to=" + CGI.escape(request.params['return_to'] || '')
54 @raw_info ||= access_token.get("/auth/josh_id/user.json?oauth_token=#{access_token.token}").parsed