Class: Keyrod::FedcloudClient

Inherits:
Object
  • Object
show all
Defined in:
lib/keyrod/fedcloud_client.rb

Constant Summary collapse

PROJECTS_PATH =
'/v3/auth/projects'.freeze
SCOPED_PATH =
'/v3/auth/tokens'.freeze
REDIRECT_HEADER =
'WWW-Authenticate'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFedcloudClient

Returns a new instance of FedcloudClient.



13
14
15
16
17
18
# File 'lib/keyrod/fedcloud_client.rb', line 13

def initialize
  @site = Keyrod::Settings[:site]
  @access_token = Keyrod::Settings[:'access-token']
  @auth_path = "/v3/OS-FEDERATION/identity_providers/#{Keyrod::Settings[:'identity-provider']}/protocols/oidc/auth"
  @ssl = Keyrod::Settings[:ssl]
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



7
8
9
# File 'lib/keyrod/fedcloud_client.rb', line 7

def access_token
  @access_token
end

#auth_pathObject (readonly)

Returns the value of attribute auth_path.



7
8
9
# File 'lib/keyrod/fedcloud_client.rb', line 7

def auth_path
  @auth_path
end

#siteObject (readonly)

Returns the value of attribute site.



7
8
9
# File 'lib/keyrod/fedcloud_client.rb', line 7

def site
  @site
end

#sslObject (readonly)

Returns the value of attribute ssl.



7
8
9
# File 'lib/keyrod/fedcloud_client.rb', line 7

def ssl
  @ssl
end

Instance Method Details

#projects(unscoped_token) ⇒ Object



25
26
27
28
# File 'lib/keyrod/fedcloud_client.rb', line 25

def projects(unscoped_token)
  response = handle_response(projects_params(unscoped_token), error_message: 'Response for getting list of projects was')
  parse_projects(response.body)
end

#scoped_token(unscoped_token, project) ⇒ Object



30
31
32
33
34
# File 'lib/keyrod/fedcloud_client.rb', line 30

def scoped_token(unscoped_token, project)
  response = handle_response(scoped_token_params, body: scoped_token_body(unscoped_token, project),
                                                  error_message: 'Response for getting scoped token was')
  response.headers[:'X-Subject-Token']
end

#unscoped_tokenObject



20
21
22
23
# File 'lib/keyrod/fedcloud_client.rb', line 20

def unscoped_token
  response = handle_response(unscoped_token_params, error_message: 'Response for getting unscoped token was')
  response.headers[:'X-Subject-Token']
end