Class: HolisticAuth::Providers::Stub
Constant Summary
collapse
- SETTINGS =
{
client_id: 'stub_cl_id',
client_secret: 'stub_cl_sec',
site: 'https://example.org',
token_url: '/extoken',
api_key: 'api_key',
user_info_url: 'http://example.org/info',
}.freeze
- STUB_SAMPLE_TOKEN =
{
token: 'ya29.token',
refresh_token: '1/refresh',
expires_in: 3600,
}.freeze
Instance Attribute Summary
#api_key, #client_id, #client_secret, #oauth2_client, #site, #tenant_id, #token_url, #user_info_url
Instance Method Summary
collapse
#add_secrets, #empty?, #full_site_url, #present?, #secrets, #site_token_url, #to_hash
Constructor Details
#initialize(options = {}) ⇒ Stub
Returns a new instance of Stub.
19
20
21
22
23
24
25
|
# File 'lib/holistic_auth/providers/stub.rb', line 19
def initialize(options = {})
super(options)
@client_id ||= settings[:client_id]
@client_secret ||= settings[:client_secret]
@api_key ||= settings[:api_key]
end
|
Instance Method Details
#exchange(_, __) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/holistic_auth/providers/stub.rb', line 35
def exchange(_, __)
@client = OAuth2::Client.new(
client_id,
client_secret,
)
OAuth2::AccessToken.new(
@client,
STUB_SAMPLE_TOKEN[:token],
refresh_token: STUB_SAMPLE_TOKEN[:refresh_token],
expires_in: STUB_SAMPLE_TOKEN[:expires_in],
)
end
|
#name ⇒ Object
31
32
33
|
# File 'lib/holistic_auth/providers/stub.rb', line 31
def name
:stub
end
|
#retrieve_user_info(_access_token) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/holistic_auth/providers/stub.rb', line 49
def retrieve_user_info(_access_token)
{
email_verified: true,
email: '[email protected]',
given_name: 'first',
family_name: 'last',
profile: 'xyz',
}.with_indifferent_access
end
|
#settings ⇒ Object
27
28
29
|
# File 'lib/holistic_auth/providers/stub.rb', line 27
def settings
SETTINGS
end
|