Class: CosmosAuthentication::Service

Inherits:
Cosmos::Service
  • Object
show all
Defined in:
lib/cosmos_authentication/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



7
8
9
# File 'lib/cosmos_authentication/service.rb', line 7

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



7
8
9
# File 'lib/cosmos_authentication/service.rb', line 7

def client_secret
  @client_secret
end

#resource_owner_classObject



58
59
60
# File 'lib/cosmos_authentication/service.rb', line 58

def resource_owner_class
  @resource_owner_class || ResourceOwner
end

Instance Method Details

#default_envObject



10
11
12
13
14
15
16
17
# File 'lib/cosmos_authentication/service.rb', line 10

def default_env
  super.merge({
    data: {
      client_id:      client_id,
      client_secret:  client_secret
    }
  })
end

#get_token_via_code(code) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/cosmos_authentication/service.rb', line 19

def get_token_via_code(code)
  get_token({
    client_id:      client_id,
    client_secret:  client_secret,
    grant_type:     'code',
    code:           code
  })
end

#get_token_via_password(username, password, scope = '') ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/cosmos_authentication/service.rb', line 28

def get_token_via_password(username, password, scope = '')
  get_token({
    client_id:      client_id,
    client_secret:  client_secret,
    grant_type:     'password',
    username:       username,
    password:       password,
    scope:          scope
  })
end

#get_token_via_refresh_token(refresh_token, scope = '') ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/cosmos_authentication/service.rb', line 39

def get_token_via_refresh_token(refresh_token, scope = '')
  get_token({
    client_id:      client_id,
    client_secret:  client_secret,
    grant_type:     'refresh_token',
    refresh_token:  refresh_token
  })
end

#providersObject



48
49
50
# File 'lib/cosmos_authentication/service.rb', line 48

def providers
  get_providers
end

#resource_owner(access_token) ⇒ Object



52
53
54
55
56
# File 'lib/cosmos_authentication/service.rb', line 52

def resource_owner(access_token)
  resource_owner_class.new.tap do |resource_owner|
    resource_owner.collection = get_resource_owner(access_token)
  end
end