onelogin 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +4 -2
- data/CODE_OF_CONDUCT.md +54 -29
- data/Gemfile +4 -2
- data/LICENSE +22 -0
- data/README.md +300 -6
- data/bin/console +1 -1
- data/bin/setup +0 -2
- data/lib/onelogin/api/client.rb +1503 -0
- data/lib/onelogin/api/cursor.rb +89 -0
- data/lib/onelogin/api/models/app.rb +22 -0
- data/lib/onelogin/api/models/device.rb +16 -0
- data/lib/onelogin/api/models/embed_app.rb +31 -0
- data/lib/onelogin/api/models/event.rb +48 -0
- data/lib/onelogin/api/models/event_type.rb +17 -0
- data/lib/onelogin/api/models/group.rb +17 -0
- data/lib/onelogin/api/models/mfa.rb +26 -0
- data/lib/onelogin/api/models/onelogin_token.rb +20 -0
- data/lib/onelogin/api/models/rate_limit.rb +17 -0
- data/lib/onelogin/api/models/role.rb +16 -0
- data/lib/onelogin/api/models/saml_endpoint_response.rb +18 -0
- data/lib/onelogin/api/models/session_token_info.rb +21 -0
- data/lib/onelogin/api/models/session_token_mfa_info.rb +26 -0
- data/lib/onelogin/api/models/user.rb +125 -0
- data/lib/onelogin/api/models/user_data.rb +13 -0
- data/lib/onelogin/api/models/user_metadata.rb +13 -0
- data/lib/onelogin/api/models.rb +16 -0
- data/lib/onelogin/api/util/constants.rb +65 -0
- data/lib/onelogin/api/util/url_builder.rb +21 -0
- data/lib/onelogin/api/util.rb +11 -0
- data/lib/onelogin/api.rb +2 -0
- data/lib/onelogin/version.rb +3 -3
- data/lib/onelogin.rb +1 -5
- data/onelogin.gemspec +40 -22
- metadata +70 -20
- data/LICENSE.txt +0 -21
@@ -0,0 +1,89 @@
|
|
1
|
+
# Cursor
|
2
|
+
#
|
3
|
+
# Used for paginating requests to the OneLogin API
|
4
|
+
#
|
5
|
+
# Returns an enumerable object
|
6
|
+
class Cursor
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
# Create a new instance of the Cursor.
|
10
|
+
#
|
11
|
+
# @param url [String] The url of the API endpoint
|
12
|
+
# @param options [Hash] Configuation options
|
13
|
+
#
|
14
|
+
def initialize(url, options = {})
|
15
|
+
@url = url
|
16
|
+
@options = options
|
17
|
+
|
18
|
+
@model = options[:model]
|
19
|
+
@headers = options[:headers] || {}
|
20
|
+
@params = options[:params] || {}
|
21
|
+
@max_results = options[:max_results]
|
22
|
+
|
23
|
+
@collection = []
|
24
|
+
@after_cursor = options.fetch(:after_cursor, nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
def each(start = 0)
|
28
|
+
return to_enum(:each, start) unless block_given?
|
29
|
+
|
30
|
+
Array(@collection[start..-1]).each do |item|
|
31
|
+
if @model
|
32
|
+
yield(@model.new(item))
|
33
|
+
else
|
34
|
+
yield(item)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
unless last?
|
39
|
+
start = [@collection.size, start].max
|
40
|
+
|
41
|
+
fetch_next_page
|
42
|
+
|
43
|
+
each(start, &Proc.new)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def fetch_next_page
|
50
|
+
@params = @params.merge(after_cursor: @after_cursor) if @after_cursor
|
51
|
+
|
52
|
+
response = HTTParty.get(
|
53
|
+
@url,
|
54
|
+
headers: @headers,
|
55
|
+
query: @params
|
56
|
+
)
|
57
|
+
|
58
|
+
json = response.parsed_response
|
59
|
+
|
60
|
+
@collection += if results_remaining < json['data'].size
|
61
|
+
json['data'].slice(0, results_remaining)
|
62
|
+
else
|
63
|
+
json['data']
|
64
|
+
end
|
65
|
+
|
66
|
+
@after_cursor = after_cursor(json)
|
67
|
+
@last_cursor_empty = @after_cursor.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
def after_cursor(json)
|
71
|
+
return unless json['pagination']
|
72
|
+
|
73
|
+
json['pagination'].fetch('after_cursor', nil)
|
74
|
+
end
|
75
|
+
|
76
|
+
def results_remaining
|
77
|
+
@max_results - @collection.size
|
78
|
+
end
|
79
|
+
|
80
|
+
def fetch_completed?
|
81
|
+
return false unless @max_results
|
82
|
+
|
83
|
+
@collection.size >= @max_results
|
84
|
+
end
|
85
|
+
|
86
|
+
def last?
|
87
|
+
@last_cursor_empty || fetch_completed?
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class App
|
6
|
+
|
7
|
+
attr_accessor :id, :name, :icon, :provisioned
|
8
|
+
attr_accessor :extension, :login_id, :personal
|
9
|
+
|
10
|
+
def initialize(data)
|
11
|
+
@id = data['id']
|
12
|
+
@name = data['name']
|
13
|
+
@icon = data['icon']
|
14
|
+
@provisioned = data['provisioned']
|
15
|
+
@extension = data['extension']
|
16
|
+
@login_id = data['login_id']
|
17
|
+
@personal = data['personal']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class EmbedApp
|
6
|
+
|
7
|
+
attr_accessor :id, :name, :icon, :provisioned, :extension_required, :login_id, :personal
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
|
12
|
+
@id = data['id'].to_i
|
13
|
+
@name = data['name'].to_s
|
14
|
+
@icon = data['icon']
|
15
|
+
@provisioned = data['provisioned'].to_i
|
16
|
+
@extension_required = truthy?('extension_required')
|
17
|
+
@login_id = data['login_id'].to_i
|
18
|
+
@personal = truthy?('personal')
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def truthy?(attribute_name)
|
24
|
+
return false unless @data[attribute_name]
|
25
|
+
|
26
|
+
['yes', 'true', '1'].include? @data[attribute_name].to_s.downcase
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class Event
|
6
|
+
|
7
|
+
attr_accessor :id, :created_at, :account_id, :user_id, :user_name, :event_type_id,
|
8
|
+
:notes, :ipaddr, :actor_user_id, :actor_user_name, :assuming_acting_user_id,
|
9
|
+
:role_id, :role_name, :app_id, :group_id, :group_name, :otp_device_id,
|
10
|
+
:otp_device_name, :policy_id, :policy_name, :actor_system, :custom_message,
|
11
|
+
:operation_name, :directory_sync_run_id, :directory_id, :resolution, :client_id,
|
12
|
+
:resource_type_id, :error_description
|
13
|
+
|
14
|
+
def initialize(data)
|
15
|
+
@id = data['id']
|
16
|
+
@created_at = data['created_at']? Time.iso8601(data['created_at']) : nil
|
17
|
+
@account_id = data['account_id']
|
18
|
+
@user_id = data['user_id']
|
19
|
+
@user_name = data['user_name'].to_s
|
20
|
+
@event_type_id = data['event_type_id']
|
21
|
+
@notes = data['notes'].to_s
|
22
|
+
@ipaddr = data['ipaddr'].to_s
|
23
|
+
@actor_user_id = data['actor_user_id']
|
24
|
+
@actor_user_name = data['actor_user_name'].to_s
|
25
|
+
@assuming_acting_user_id = data['assuming_acting_user_id']
|
26
|
+
@role_id = data['role_id']
|
27
|
+
@role_name = data['role_name'].to_s
|
28
|
+
@app_id = data['app_id']
|
29
|
+
@group_id = data['group_id']
|
30
|
+
@group_name = data['group_name'].to_s
|
31
|
+
@otp_device_id = data['otp_device_id']
|
32
|
+
@otp_device_name = data['otp_device_name'].to_s
|
33
|
+
@policy_id = data['policy_id']
|
34
|
+
@policy_name = data['policy_name'].to_s
|
35
|
+
@actor_system = data['actor_system'].to_s
|
36
|
+
@custom_message = data['custom_message'].to_s
|
37
|
+
@operation_name = data['operation_name'].to_s
|
38
|
+
@directory_sync_run_id = data['directory_sync_run_id']
|
39
|
+
@directory_id = data['directory_id']
|
40
|
+
@resolution = data['resolution'].to_s
|
41
|
+
@client_id = data['client_id']
|
42
|
+
@resource_type_id = data['resource_type_id']
|
43
|
+
@error_description = data['error_description'].to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class EventType
|
6
|
+
|
7
|
+
attr_accessor :id, :name, :reference
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@id = data['id']
|
11
|
+
@name = data['name'].to_s
|
12
|
+
@reference = data['reference'].to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class Group
|
6
|
+
|
7
|
+
attr_accessor :id, :name, :reference
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@id = data['id']
|
11
|
+
@name = data['name'].to_s
|
12
|
+
@reference = data['reference'].to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class MFA
|
6
|
+
|
7
|
+
attr_accessor :state_token, :callback_url, :user, :devices
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
unless data['user'].empty?
|
11
|
+
@user = OneLogin::Api::Models::User.new(data['user']) # Partial info
|
12
|
+
end
|
13
|
+
@state_token = data['state_token'].to_s
|
14
|
+
@callback_url = data['callback_url'].to_s
|
15
|
+
@devices = []
|
16
|
+
unless data['devices'].empty?
|
17
|
+
data['devices'].each do |device_data|
|
18
|
+
@devices << OneLogin::Api::Models::Device.new(device_data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class OneLoginToken
|
6
|
+
|
7
|
+
attr_accessor :access_token, :refresh_token, :account_id, :token_type, :created_at, :expires_in
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@access_token = data['access_token'].to_s
|
11
|
+
@refresh_token = data['refresh_token'].to_s
|
12
|
+
@account_id = data['account_id']
|
13
|
+
@token_type = data['token_type']
|
14
|
+
@created_at = Time.iso8601(data['created_at'])
|
15
|
+
@expires_in = data['expires_in']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class RateLimit
|
6
|
+
|
7
|
+
attr_accessor :limit, :remaining, :reset
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@limit = data['X-RateLimit-Limit']
|
11
|
+
@remaining = data['X-RateLimit-Remaining']
|
12
|
+
@reset = data['X-RateLimit-Reset']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class SAMLEndpointResponse
|
6
|
+
|
7
|
+
attr_accessor :type, :message, :mfa, :saml_response
|
8
|
+
|
9
|
+
def initialize(status_type, status_message)
|
10
|
+
@type = status_type
|
11
|
+
@message = status_message
|
12
|
+
@saml_response = nil
|
13
|
+
@mfa = nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class SessionTokenInfo
|
6
|
+
|
7
|
+
attr_accessor :status, :user, :return_to_url, :expires_at, :session_token
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@status = data['status'].to_s
|
11
|
+
unless data['user'].empty?
|
12
|
+
@user = OneLogin::Api::Models::User.new(data['user']) # Partial info
|
13
|
+
end
|
14
|
+
@return_to_url = data['return_to_url'].to_s
|
15
|
+
@expires_at = Time.parse(data['expires_at'])
|
16
|
+
@session_token = data['session_token'].to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class SessionTokenMFAInfo
|
6
|
+
|
7
|
+
attr_accessor :user, :state_token, :callback_url, :devices
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
unless data['user'].empty?
|
11
|
+
@user = OneLogin::Api::Models::User.new(data['user']) # Partial info
|
12
|
+
end
|
13
|
+
@state_token = data['state_token'].to_s
|
14
|
+
@callback_url = data['callback_url'].to_s
|
15
|
+
@devices = []
|
16
|
+
unless data['devices'].empty?
|
17
|
+
data['devices'].each do |device_data|
|
18
|
+
@devices << OneLogin::Api::Models::Device.new(device_data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class User
|
6
|
+
|
7
|
+
attr_accessor :id, :external_id, :email, :username, :firstname, :lastname, :distinguished_name,
|
8
|
+
:phone, :company, :department, :status, :member_of, :samaccountname, :userprincipalname,
|
9
|
+
:group_id, :role_ids, :custom_attributes, :openid_name, :locale_code, :comment, :directory_id,
|
10
|
+
:manager_ad_id, :trusted_idp_id, :activated_at, :created_at, :updated_at,
|
11
|
+
:password_changed_at, :invitation_sent_at, :invalid_login_attempts, :last_login, :locked_until
|
12
|
+
|
13
|
+
def initialize(data)
|
14
|
+
@id = data['id']
|
15
|
+
@external_id = data['external_id']
|
16
|
+
@email = data['email'].to_s
|
17
|
+
@username = data['username'].to_s
|
18
|
+
@firstname = data['firstname'].to_s
|
19
|
+
@lastname = data['lastname'].to_s
|
20
|
+
@distinguished_name = data['distinguished_name'].to_s
|
21
|
+
@phone = data['phone'].to_s
|
22
|
+
@company = data['company'].to_s
|
23
|
+
@department = data['department'].to_s
|
24
|
+
@status = data['status']
|
25
|
+
@member_of = data['member_of'].to_s
|
26
|
+
@samaccountname = data['samaccountname'].to_s
|
27
|
+
@userprincipalname = data['userprincipalname'].to_s
|
28
|
+
@group_id = data['group_id']? data['group_id'].to_i : nil
|
29
|
+
@role_ids = data['role_id']? data['role_id'] : []
|
30
|
+
@custom_attributes = data['custom_attributes'] ? data['custom_attributes'] : []
|
31
|
+
@openid_name = data['openid_name'].to_s
|
32
|
+
@locale_code = data['locale_code'].to_s
|
33
|
+
@comment = data['comment'].to_s
|
34
|
+
@directory_id = data['directory_id']
|
35
|
+
@manager_ad_id = data['manager_ad_id']
|
36
|
+
@trusted_idp_id = data['trusted_idp_id']
|
37
|
+
@activated_at = data['activated_at']? Time.iso8601(data['activated_at']) : nil
|
38
|
+
@created_at = data['created_at']? Time.iso8601(data['created_at']) : nil
|
39
|
+
@password_changed_at = data['password_changed_at']? Time.iso8601(data['password_changed_at']) : nil
|
40
|
+
@invitation_sent_at = data['invitation_sent_at']? Time.iso8601(data['invitation_sent_at']) : nil
|
41
|
+
@invalid_login_attempts = data['invalid_login_attempts']
|
42
|
+
@last_login = data['last_login']? Time.iso8601(data['last_login']) : nil
|
43
|
+
@locked_until = data['locked_until']? Time.iso8601(data['locked_until']) : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_role_ids
|
47
|
+
@role_ids
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_role_ids
|
51
|
+
@group_id
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_user_data
|
55
|
+
user_data = UserData.new
|
56
|
+
user_data.id = @id
|
57
|
+
user_data.external_id = @external_id
|
58
|
+
user_data.email = @email
|
59
|
+
user_data.username = @username
|
60
|
+
user_data.firstname = @firstname
|
61
|
+
user_data.lastname = @lastname
|
62
|
+
user_data.distinguished_name = @distinguished_name
|
63
|
+
user_data.phone = @phone
|
64
|
+
user_data.company = @company
|
65
|
+
user_data.department = @department
|
66
|
+
user_data.status = @status
|
67
|
+
user_data.member_of = @member_of
|
68
|
+
user_data.samaccountname = @samaccountname
|
69
|
+
user_data.userprincipalname = @userprincipalname
|
70
|
+
user_data.openid_name = @openid_name
|
71
|
+
user_data.locale_code = @locale_code
|
72
|
+
user_data.directory_id = @directory_id
|
73
|
+
user_data.manager_ad_id = @manager_ad_id
|
74
|
+
user_data.trusted_idp_id = @trusted_idp_id
|
75
|
+
return user_data
|
76
|
+
end
|
77
|
+
|
78
|
+
def get_user_metadata
|
79
|
+
user_metadata = UserMetadata.new
|
80
|
+
user_metadata.id = @id
|
81
|
+
user_metadata.activated_at = @activated_at
|
82
|
+
user_metadata.created_at = @created_at
|
83
|
+
user_metadata.updated_at = @updated_at
|
84
|
+
user_metadata.password_changed_at = @password_changed_at
|
85
|
+
user_metadata.invalid_login_attempts = @invalid_login_attempts
|
86
|
+
user_metadata.invitation_sent_at = @invitation_sent_at
|
87
|
+
user_metadata.last_login = @last_login
|
88
|
+
user_metadata.locked_until = @locked_until
|
89
|
+
user_metadata.comment = @comment
|
90
|
+
|
91
|
+
return user_metadata
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_custom_attributes
|
95
|
+
@custom_attributes
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_user_params
|
99
|
+
return {
|
100
|
+
"external_id"=> self.external_id,
|
101
|
+
"email"=> self.email,
|
102
|
+
"username"=> self.username,
|
103
|
+
"firstname"=> self.firstname,
|
104
|
+
"lastname"=> self.lastname,
|
105
|
+
"distinguished_name"=> self.distinguished_name,
|
106
|
+
"phone"=> self.phone,
|
107
|
+
"company"=> self.company,
|
108
|
+
"department"=> self.department,
|
109
|
+
"status"=> self.status,
|
110
|
+
"member_of"=> self.member_of,
|
111
|
+
"samaccountname"=> self.samaccountname,
|
112
|
+
"invalid_login_attempts"=> self.invalid_login_attempts,
|
113
|
+
"userprincipalname"=> self.userprincipalname,
|
114
|
+
"group_id"=> self.group_id,
|
115
|
+
"locale_code"=> self.locale_code,
|
116
|
+
"openid_name"=> self.openid_name,
|
117
|
+
"directory_id"=> self.directory_id,
|
118
|
+
"manager_ad_id"=> self.manager_ad_id,
|
119
|
+
"trusted_idp_id"=> self.trusted_idp_id
|
120
|
+
}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class UserData
|
6
|
+
|
7
|
+
attr_accessor :id, :external_id, :email, :username, :firstname, :lastname, :distinguished_name,
|
8
|
+
:phone, :company, :department, :status, :member_of, :samaccountname, :userprincipalname,
|
9
|
+
:openid_name, :locale_code, :directory_id, :manager_ad_id, :trusted_idp_id
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class UserMetadata
|
6
|
+
|
7
|
+
attr_accessor :id, :activated_at, :created_at, :updated_at, :password_changed_at,
|
8
|
+
:invitation_sent_at, :invalid_login_attempts, :last_login, :locked_until,
|
9
|
+
:comment
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'onelogin/api/models/app'
|
2
|
+
require 'onelogin/api/models/device'
|
3
|
+
require 'onelogin/api/models/event'
|
4
|
+
require 'onelogin/api/models/event_type'
|
5
|
+
require 'onelogin/api/models/group'
|
6
|
+
require 'onelogin/api/models/mfa'
|
7
|
+
require 'onelogin/api/models/onelogin_token'
|
8
|
+
require 'onelogin/api/models/rate_limit'
|
9
|
+
require 'onelogin/api/models/role'
|
10
|
+
require 'onelogin/api/models/saml_endpoint_response'
|
11
|
+
require 'onelogin/api/models/session_token_info'
|
12
|
+
require 'onelogin/api/models/session_token_mfa_info'
|
13
|
+
require 'onelogin/api/models/user_data'
|
14
|
+
require 'onelogin/api/models/user_metadata'
|
15
|
+
require 'onelogin/api/models/user'
|
16
|
+
require 'onelogin/api/models/embed_app'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Util
|
4
|
+
# Constants class of the OneLogin's Ruby SDK.
|
5
|
+
#
|
6
|
+
# This class defines all the constants that will be used
|
7
|
+
# in the OneLogin's Ruby SDK.
|
8
|
+
#
|
9
|
+
module Constants
|
10
|
+
# OAuth2 Tokens URLs
|
11
|
+
TOKEN_REQUEST_URL = "https://api.%s.onelogin.com/auth/oauth2/token"
|
12
|
+
TOKEN_REFRESH_URL = "https://api.%s.onelogin.com/auth/oauth2/token"
|
13
|
+
TOKEN_REVOKE_URL = "https://api.%s.onelogin.com/auth/oauth2/revoke"
|
14
|
+
GET_RATE_URL = "https://api.%s.onelogin.com/auth/rate_limit"
|
15
|
+
|
16
|
+
# User URLs
|
17
|
+
GET_USERS_URL = "https://api.%s.onelogin.com/api/1/users"
|
18
|
+
GET_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s"
|
19
|
+
GET_APPS_FOR_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/apps"
|
20
|
+
GET_ROLES_FOR_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/roles"
|
21
|
+
GET_CUSTOM_ATTRIBUTES_URL = "https://api.%s.onelogin.com/api/1/users/custom_attributes"
|
22
|
+
CREATE_USER_URL = "https://api.%s.onelogin.com/api/1/users"
|
23
|
+
SESSION_LOGIN_TOKEN_URL = "https://api.%s.onelogin.com/api/1/login/auth"
|
24
|
+
GET_TOKEN_VERIFY_FACTOR = "https://api.%s.onelogin.com/api/1/login/verify_factor"
|
25
|
+
SESSION_API_TOKEN_URL = "https://admin.%s.onelogin.com/session_via_api_token"
|
26
|
+
UPDATE_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s"
|
27
|
+
DELETE_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s"
|
28
|
+
ADD_ROLE_TO_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/add_roles"
|
29
|
+
DELETE_ROLE_TO_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/remove_roles"
|
30
|
+
SET_PW_CLEARTEXT = "https://api.%s.onelogin.com/api/1/users/set_password_clear_text/%s"
|
31
|
+
SET_PW_SALT = "https://api.%s.onelogin.com/api/1/users/set_password_using_salt/%s"
|
32
|
+
SET_CUSTOM_ATTRIBUTE_TO_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/set_custom_attributes"
|
33
|
+
LOG_USER_OUT_URL = "https://api.%s.onelogin.com/api/1/users/%s/logout"
|
34
|
+
LOCK_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/lock_user"
|
35
|
+
|
36
|
+
# Role URLs
|
37
|
+
GET_ROLES_URL = "https://api.%s.onelogin.com/api/1/roles"
|
38
|
+
CREATE_ROLE_URL = "https://api.%s.onelogin.com/api/1/roles"
|
39
|
+
GET_ROLE_URL = "https://api.%s.onelogin.com/api/1/roles/%s"
|
40
|
+
|
41
|
+
# Event URLS
|
42
|
+
GET_EVENT_TYPES_URL = "https://api.%s.onelogin.com/api/1/events/types"
|
43
|
+
GET_EVENTS_URL = "https://api.%s.onelogin.com/api/1/events"
|
44
|
+
CREATE_EVENT_URL = "https://api.%s.onelogin.com/api/1/events"
|
45
|
+
GET_EVENT_URL = "https://api.%s.onelogin.com/api/1/events/%s"
|
46
|
+
|
47
|
+
# Group URLs
|
48
|
+
GET_GROUPS_URL = "https://api.%s.onelogin.com/api/1/groups"
|
49
|
+
CREATE_GROUP_URL = "https://api.%s.onelogin.com/api/1/groups"
|
50
|
+
GET_GROUP_URL = "https://api.%s.onelogin.com/api/1/groups/%s"
|
51
|
+
|
52
|
+
# SAML Assertion URLs
|
53
|
+
GET_SAML_ASSERTION_URL = "https://api.%s.onelogin.com/api/1/saml_assertion"
|
54
|
+
GET_SAML_VERIFY_FACTOR = "https://api.%s.onelogin.com/api/1/saml_assertion/verify_factor"
|
55
|
+
|
56
|
+
# Invite Link URLS
|
57
|
+
GENERATE_INVITE_LINK_URL = "https://api.%s.onelogin.com/api/1/invites/get_invite_link"
|
58
|
+
SEND_INVITE_LINK_URL = "https://api.%s.onelogin.com/api/1/invites/send_invite_link"
|
59
|
+
|
60
|
+
# Embed Apps URL
|
61
|
+
EMBED_APP_URL = "https://api.onelogin.com/client/apps/embed2"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Util
|
4
|
+
module UrlBuilder
|
5
|
+
|
6
|
+
# Build the URL of the API endpoint
|
7
|
+
#
|
8
|
+
# @param base [String] Base of the endpoint
|
9
|
+
# @param obj_id [String, nil] Id of the referenced object
|
10
|
+
#
|
11
|
+
def url_for(base, obj_id=nil)
|
12
|
+
if obj_id.nil? || obj_id.to_s.empty?
|
13
|
+
base % [@region]
|
14
|
+
else
|
15
|
+
base % [@region, obj_id]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/onelogin/api.rb
ADDED