Class: OmniAuth::Strategies::Desk
- Inherits:
-
OAuth
- Object
- OAuth
- OmniAuth::Strategies::Desk
- Defined in:
- lib/omniauth/strategies/desk.rb
Overview
An omniauth 1.0 strategy for Desk.com authorization
Instance Method Summary collapse
- #callback_phase ⇒ Object
- #get_identifier ⇒ Object
- #identifier ⇒ Object
-
#raw_info ⇒ Object
Return info gathered from the verify_credentials API call.
- #request_phase ⇒ Object
- #uri?(uri) ⇒ Boolean
-
#user_info ⇒ Object
Provide the “user” portion of the raw_info.
- #validate_site(site) ⇒ Object
Instance Method Details
#callback_phase ⇒ Object
84 85 86 87 |
# File 'lib/omniauth/strategies/desk.rb', line 84 def callback_phase ..site = session[:site] if session[:site] super end |
#get_identifier ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/omniauth/strategies/desk.rb', line 72 def get_identifier f = OmniAuth::Form.new :title => 'Desk.com Authorization' f.text_field 'Desk.com Site', .site_param.to_s f.html '<p><strong>Hint:</strong> https://YOURSITE.desk.com' f. 'Login' f.to_response end |
#identifier ⇒ Object
51 52 53 54 55 |
# File 'lib/omniauth/strategies/desk.rb', line 51 def identifier session[:site] = ..site = .site || validate_site(request.params[.site_param.to_s]) session[:site] = ..site = nil if ..site == '' ..site end |
#raw_info ⇒ Object
Return info gathered from the verify_credentials API call
40 41 42 43 44 |
# File 'lib/omniauth/strategies/desk.rb', line 40 def raw_info @raw_info ||= MultiJson.decode(access_token.get('/api/v2/users/me').body) if access_token rescue ::Errno::ETIMEDOUT raise ::Timeout::Error end |
#request_phase ⇒ Object
80 81 82 |
# File 'lib/omniauth/strategies/desk.rb', line 80 def request_phase identifier ? super : get_identifier end |
#uri?(uri) ⇒ Boolean
57 58 59 60 61 62 63 64 |
# File 'lib/omniauth/strategies/desk.rb', line 57 def uri?(uri) uri = URI.parse(uri) uri.scheme == 'https' rescue URI::BadURIError false rescue URI::InvalidURIError false end |
#user_info ⇒ Object
Provide the “user” portion of the raw_info
47 48 49 |
# File 'lib/omniauth/strategies/desk.rb', line 47 def user_info @user_info ||= raw_info.nil? ? {} : raw_info end |
#validate_site(site) ⇒ Object
66 67 68 69 70 |
# File 'lib/omniauth/strategies/desk.rb', line 66 def validate_site(site) if site and site != '' uri?(site) ? site : "https://#{site}.desk.com" end end |