lib/databasedotcom-oauth2.rb in databasedotcom-oauth2-0.1.8 vs lib/databasedotcom-oauth2.rb in databasedotcom-oauth2-0.1.9
- old
+ new
@@ -48,15 +48,10 @@
client.refresh_token = token.refresh_token
end
client
end
- #def set_org_and_user_id(orgid, userid)
- # @org_id = orgid
- # @user_id = userid
- #end
-
def org_id=(val)
@org_id = val
end
def user_id=(val)
@@ -99,17 +94,19 @@
unless options.nil?
@endpoints = self.class.sanitize_endpoints(options[:endpoints])
@token_encryption_key = options[:token_encryption_key]
@path_prefix = options[:path_prefix]
@on_failure = options[:on_failure]
- @scope = options[:scope]
@display = options[:display]
@immediate = options[:immediate]
- @scope_override = options[:scope_override] || false
+ @prompt = options[:prompt]
+ @scope = options[:scope]
@display_override = options[:display_override] || false
@immediate_override = options[:immediate_override] || false
- @api_version = options[:api_version] || "24.0"
+ @prompt_override = options[:prompt_override] || false
+ @scope_override = options[:scope_override] || false
+ @api_version = options[:api_version] || "25.0"
@debugging = options[:debugging] || false
end
fail "\n\ndatabasedotcom-oauth2 initialization error! :endpoints parameter " \
+ "is invalid. Do something like this:\n\nuse Databasedotcom::OAuth2::Web" \
@@ -178,22 +175,24 @@
#build params hash to be passed to ouath2 authorize redirect url
auth_params = {
:redirect_uri => "#{full_host}#{@path_prefix}/callback",
:state => state.to_str
}
- auth_params[:scope] = @scope unless @scope.nil? || @scope.strip.empty?
auth_params[:display] = @display unless @display.nil?
auth_params[:immediate] = @immediate unless @immediate.nil?
-
+ auth_params[:prompt] = @prompt unless @prompt.nil?
+ auth_params[:scope] = @scope unless @scope.nil? || @scope.strip.empty?
+
#overrides
overrides = {}
+ overrides[:display] = request.params["display"] unless !@display_override || request.params["display"].nil?
+ overrides[:immediate] = request.params["immediate"] unless !@immediate_override || request.params["immediate"].nil?
+ overrides[:prompt] = request.params["prompt"] unless !@prompt_override || request.params["prompt"].nil?
if @scope_override
scope = (self.class.param_repeated(request.url, :scope) || []).join(" ")
overrides[:scope] = scope unless scope.nil? || scope.strip.empty?
end
- overrides[:display] = request.params["display"] unless !@display_override || request.params["display"].nil?
- overrides[:immediate] = request.params["immediate"] unless !@immediate_override || request.params["immediate"].nil?
auth_params.merge!(overrides)
#do redirect
redirect_url = client(mydomain || endpoint, keys[:key], keys[:secret]).auth_code.authorize_url(auth_params)
puts "redirecting to #{redirect_url}..." if @debugging
@@ -317,10 +316,9 @@
full_host = ENV['ORIGIN']
if full_host.nil? || full_host.strip.empty?
full_host = URI.parse(request.url.gsub(/\?.*$/,''))
full_host.path = ''
full_host.query = nil
- #sometimes the url is actually showing http inside rails because the other layers (like nginx) have handled the ssl termination.
full_host.scheme = 'https' if(request.env['HTTP_X_FORWARDED_PROTO'] == 'https')
full_host = full_host.to_s
end
full_host
end