Class: Mdm::Enrollment::Auth

Inherits:
Service::Base show all
Defined in:
lib/mdm/enrollment/service/auth.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service::Base

accepted_params, #authenticate?, available_services, #method, #params=, #path, #result, #start

Class Method Details

.tokenObject



20
21
22
# File 'lib/mdm/enrollment/service/auth.rb', line 20

def token
  @@token ||= new.obtain_token
end

.update_token_from_response(response) ⇒ Object



24
25
26
27
28
# File 'lib/mdm/enrollment/service/auth.rb', line 24

def update_token_from_response(response)
  if response && token = response.headers['x-adm-auth-session']
    @@token = token
  end
end

Instance Method Details

#obtain_tokenObject



32
33
34
35
36
37
38
# File 'lib/mdm/enrollment/service/auth.rb', line 32

def obtain_token
  client.get '/session',
         headers: {
           'Authorization' => authorization_header
         }
  client.response['auth_session_token']
end

#paramsObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/mdm/enrollment/service/auth.rb', line 40

def params
  @params ||= {
    oauth_consumer_key: consumer_key,
    oauth_token: access_token,
    oauth_nonce: nonce,
    oauth_timestamp: Time.now.getutc.to_i.to_s,
    oauth_version: '1.0',
    oauth_signature_method: 'HMAC-SHA1'
  }
end