Class: OmniAuth::Strategies::Opscode
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Opscode
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/opscode.rb
Instance Method Summary collapse
Instance Method Details
#callback_phase ⇒ Object
23 24 25 26 |
# File 'lib/omniauth/strategies/opscode.rb', line 23 def callback_phase return fail!(:invalid_credentials) unless identity super end |
#identity ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/opscode.rb', line 36 def identity @identity ||= nil return @identity if @identity conn = Faraday.new(:url => .chef_webui_url, :ssl => {:verify => false}) do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP faraday.use :cookie_jar end conn.get("/login") response = conn.post('/login_exec', { :name => request['username'], :password => request['password'] }) if response.status == 302 && response.headers['location'] =~ /nodes$/ @identity = { :name => request['username'] } else nil end end |
#info ⇒ Object
32 33 34 |
# File 'lib/omniauth/strategies/opscode.rb', line 32 def info @identity end |
#request_phase ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/omniauth/strategies/opscode.rb', line 15 def request_phase form = OmniAuth::Form.new(:title => "Login to Opscode", :url => callback_path) form.text_field 'Username', 'username' form.password_field 'Password', 'password' form. "Login" form.to_response end |
#uid ⇒ Object
28 29 30 |
# File 'lib/omniauth/strategies/opscode.rb', line 28 def uid @identity[:name] end |