Class: Okta::DirectoryService
Constant Summary
collapse
- DEFAULT_OKTA_SCOPES =
%w[openid profile email address phone offline_access device_sso].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
configuration, #raise_backend_exception
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
Returns a new instance of DirectoryService.
12
13
14
|
# File 'lib/okta/directory_service.rb', line 12
def initialize
@okta_service = Okta::Service.new
end
|
Instance Attribute Details
#okta_service ⇒ Object
Returns the value of attribute okta_service.
10
11
12
|
# File 'lib/okta/directory_service.rb', line 10
def okta_service
@okta_service
end
|
Instance Method Details
#handle_health_server ⇒ Object
22
23
24
25
26
|
# File 'lib/okta/directory_service.rb', line 22
def handle_health_server
server = okta_service.auth_server(Settings.directory.health_server_id)
scopes = okta_service.get_server_scopes(server.body['id'])
remove_scope_keys(scopes)
end
|
#handle_nonhealth_server(category) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/okta/directory_service.rb', line 28
def handle_nonhealth_server(category)
servers = okta_service.auth_servers
server = servers.body.select { |auth_server| auth_server['name'].include?(category.downcase) }
return server if server.empty?
scopes = @okta_service.get_server_scopes(server[0]['id'])
remove_scope_keys(scopes)
end
|
#remove_base_okta_scopes(scopes) ⇒ Object
47
48
49
|
# File 'lib/okta/directory_service.rb', line 47
def remove_base_okta_scopes(scopes)
scopes.delete_if { |scope| DEFAULT_OKTA_SCOPES.include? scope['name'] }
end
|
#remove_scope_keys(scopes) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/okta/directory_service.rb', line 37
def remove_scope_keys(scopes)
parsed_scopes = scopes.body.each do |item|
item.select! { |k, _v| %w[name displayName description].include?(k.to_s) }
end
remove_base_okta_scopes(parsed_scopes)
end
|
#scopes(category) ⇒ Object
16
17
18
19
20
|
# File 'lib/okta/directory_service.rb', line 16
def scopes(category)
category == 'health' ? handle_health_server : handle_nonhealth_server(category)
end
|