Class: Superset::Authenticator
- Inherits:
-
Object
- Object
- Superset::Authenticator
show all
- Defined in:
- lib/superset/authenticator.rb
Defined Under Namespace
Classes: CredentialMissingError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(credentials) ⇒ Authenticator
Returns a new instance of Authenticator.
7
8
9
|
# File 'lib/superset/authenticator.rb', line 7
def initialize(credentials)
@credentials = credentials
end
|
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
5
6
7
|
# File 'lib/superset/authenticator.rb', line 5
def credentials
@credentials
end
|
Class Method Details
.call(credentials) ⇒ Object
11
12
13
|
# File 'lib/superset/authenticator.rb', line 11
def self.call(credentials)
self.new(credentials).access_token
end
|
Instance Method Details
#access_token ⇒ Object
15
16
17
|
# File 'lib/superset/authenticator.rb', line 15
def access_token
response_body['access_token']
end
|
#refresh_token ⇒ Object
19
20
21
|
# File 'lib/superset/authenticator.rb', line 19
def refresh_token
response_body['refresh_token']
end
|
#superset_host ⇒ Object
28
29
30
31
32
|
# File 'lib/superset/authenticator.rb', line 28
def superset_host
raise CredentialMissingError, "SUPERSET_HOST not found" unless ENV['SUPERSET_HOST'].present?
ENV['SUPERSET_HOST']
end
|
#validate_credential_existance ⇒ Object
23
24
25
26
|
# File 'lib/superset/authenticator.rb', line 23
def validate_credential_existance
raise CredentialMissingError, 'password not set' unless credentials[:password].present?
raise CredentialMissingError, 'username not set' unless credentials[:username].present?
end
|