class OmniAuth::Strategies::Chef
Public Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/chef.rb, line 38 def callback_phase @user = authenticated_user authenticated? ? super : fail!(:invalid_credentials) end
Protected Instance Methods
authenticated?()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 81 def authenticated? @user ? true : false end
authenticated_user()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 63 def authenticated_user begin uname = username # Check if username is email if (uname.include?('@')) users = chef.get_rest( "users?#{{ email: username }.to_query}" ) if (users.length > 0) uname = users.first[0] end end chef.post_rest(resource, username: uname, password: password)['user'] rescue Net::HTTPServerException end end
chef()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 85 def chef ::Chef::Config.ssl_verify_mode options.ssl_verify_mode.to_sym ::Chef::ServerAPI.new endpoint, parameters end
endpoint()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 90 def endpoint organization ? "#{options.endpoint}/#{organization}" : options.endpoint end
headers()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 94 def headers options.headers.merge({ 'x-ops-request-source' => options.source }) end
key()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 98 def key options.key_data || IO.read(File.expand_path(options.key_path, __FILE__)).strip end
organization()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 102 def organization options.organization end
parameters()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 106 def parameters { headers: headers, client_name: options.superuser, client_key: nil, raw_key: key } end
password()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 113 def password options.password ? options.password : request[:password] end
resource()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 117 def resource options.resource end
username()
click to toggle source
# File lib/omniauth/strategies/chef.rb, line 121 def username options.username ? options.username : request[:username] end