onelogin 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +70 -0
- data/examples/events-to-csv.rb +2 -2
- data/examples/rails-custom-login-page/app/assets/stylesheets/application.css +3 -3
- data/examples/rails-custom-login-page/app/controllers/sessions_controller.rb +26 -0
- data/examples/rails-custom-login-page/app/helpers/sessions_helper.rb +27 -0
- data/examples/rails-custom-login-page/app/views/dashboard/index.html.erb +41 -28
- data/examples/rails-custom-login-page/app/views/home/index.html.erb +136 -33
- data/examples/rails-custom-login-page/app/views/layouts/application.html.erb +1 -0
- data/examples/rails-custom-login-page/app/views/users/index.html.erb +7 -7
- data/examples/rails-custom-login-page/app/views/users/show.html.erb +6 -4
- data/examples/rails-custom-login-page/config/routes.rb +2 -0
- data/lib/onelogin/api/client.rb +455 -4
- data/lib/onelogin/api/cursor.rb +16 -5
- data/lib/onelogin/api/models.rb +2 -0
- data/lib/onelogin/api/models/privilege.rb +51 -0
- data/lib/onelogin/api/models/statement.rb +36 -0
- data/lib/onelogin/api/util/constants.rb +86 -0
- data/lib/onelogin/api/util/parser.rb +24 -10
- data/lib/onelogin/version.rb +1 -1
- metadata +5 -3
data/lib/onelogin/api/cursor.rb
CHANGED
@@ -24,6 +24,7 @@ class Cursor
|
|
24
24
|
@headers = options[:headers] || {}
|
25
25
|
@params = options[:params] || {}
|
26
26
|
@max_results = options[:max_results]
|
27
|
+
@container = options[:container] || 'data'
|
27
28
|
|
28
29
|
@collection = []
|
29
30
|
@after_cursor = options.fetch(:after_cursor, nil)
|
@@ -64,10 +65,16 @@ class Cursor
|
|
64
65
|
|
65
66
|
if json.nil?
|
66
67
|
raise OneLogin::Api::ApiException.new("Response could not be parsed", 500)
|
67
|
-
elsif !json.
|
68
|
+
elsif !json.has_key?(@container) && json.has_key?('status') && json["status"]["error"] == true
|
68
69
|
raise OneLogin::Api::ApiException.new(extract_error_message_from_response(response), json["status"]["code"])
|
70
|
+
elsif !json.has_key?(@container) && json.has_key?('statusCode')
|
71
|
+
raise OneLogin::Api::ApiException.new(extract_error_message_from_response(response), json["statusCode"])
|
69
72
|
else
|
70
|
-
|
73
|
+
|
74
|
+
results = json[@container]
|
75
|
+
if @container == "data"
|
76
|
+
results = results.flatten
|
77
|
+
end
|
71
78
|
|
72
79
|
@collection += if results_remaining < results.size
|
73
80
|
results.slice(0, results_remaining)
|
@@ -81,9 +88,13 @@ class Cursor
|
|
81
88
|
end
|
82
89
|
|
83
90
|
def after_cursor(json)
|
84
|
-
|
85
|
-
|
86
|
-
|
91
|
+
value = nil
|
92
|
+
if json.has_key?('pagination')
|
93
|
+
value = json['pagination'].fetch('after_cursor', nil)
|
94
|
+
elsif json.has_key?('afterCursor')
|
95
|
+
value = json['afterCursor']
|
96
|
+
end
|
97
|
+
value
|
87
98
|
end
|
88
99
|
|
89
100
|
def results_remaining
|
data/lib/onelogin/api/models.rb
CHANGED
@@ -8,11 +8,13 @@ require 'onelogin/api/models/group'
|
|
8
8
|
require 'onelogin/api/models/mfa'
|
9
9
|
require 'onelogin/api/models/onelogin_token'
|
10
10
|
require 'onelogin/api/models/otp_device'
|
11
|
+
require 'onelogin/api/models/privilege'
|
11
12
|
require 'onelogin/api/models/rate_limit'
|
12
13
|
require 'onelogin/api/models/role'
|
13
14
|
require 'onelogin/api/models/saml_endpoint_response'
|
14
15
|
require 'onelogin/api/models/session_token_info'
|
15
16
|
require 'onelogin/api/models/session_token_mfa_info'
|
17
|
+
require 'onelogin/api/models/statement'
|
16
18
|
require 'onelogin/api/models/user_data'
|
17
19
|
require 'onelogin/api/models/user_metadata'
|
18
20
|
require 'onelogin/api/models/user'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'onelogin/api/models/statement'
|
2
|
+
|
3
|
+
module OneLogin
|
4
|
+
module Api
|
5
|
+
module Models
|
6
|
+
|
7
|
+
class Privilege
|
8
|
+
|
9
|
+
attr_accessor :id, :name, :version, :statements
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
if args.length == 1
|
13
|
+
self.from_data(args[0])
|
14
|
+
else
|
15
|
+
self.from_values(args[0],args[1], args[2], args[3])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def from_data(data)
|
20
|
+
@id = data['id']
|
21
|
+
@name = data['name']
|
22
|
+
@version = data['privilege']['Version']
|
23
|
+
statements_data = data['privilege']['Statement']
|
24
|
+
@statements = []
|
25
|
+
for statement_data in statements_data
|
26
|
+
@statements << Statement.new(statement_data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def from_values(id, name, version, statements)
|
31
|
+
@id = id
|
32
|
+
@name = name
|
33
|
+
@version = version
|
34
|
+
@statements = []
|
35
|
+
for statement in statements
|
36
|
+
if statement.instance_of?(Statement)
|
37
|
+
@statements << statement
|
38
|
+
elsif statement.instance_of?(Hash) && statement.has_key?('Effect') && statement.has_key?('Action') && statement.has_key?('Scope')
|
39
|
+
@statements << Statement.new(statement['Effect'], statement['Action'], statement['Scope'])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_valid_actions
|
45
|
+
return
|
46
|
+
Constants.VALID_ACTIONS
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module OneLogin
|
2
|
+
module Api
|
3
|
+
module Models
|
4
|
+
|
5
|
+
class Statement
|
6
|
+
|
7
|
+
attr_accessor :effect, :actions, :scopes
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
if args.length == 1
|
11
|
+
self.from_data(args[0])
|
12
|
+
else
|
13
|
+
self.from_values(args[0], args[1], args[2])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def from_data(data)
|
18
|
+
@effect = data['Effect']? data['Effect'] : "Allow"
|
19
|
+
@actions = data['Action']? data['Action'] : []
|
20
|
+
@scopes = data['Scope']? data['Scope'] : []
|
21
|
+
end
|
22
|
+
|
23
|
+
def from_values(effect, actions, scopes)
|
24
|
+
@effect = effect
|
25
|
+
@actions = actions
|
26
|
+
@scopes = scopes
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_valid_actions
|
30
|
+
return
|
31
|
+
Constants.VALID_ACTIONS
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -67,6 +67,92 @@ module OneLogin
|
|
67
67
|
|
68
68
|
# Embed Apps URL
|
69
69
|
EMBED_APP_URL = "https://api.onelogin.com/client/apps/embed2"
|
70
|
+
|
71
|
+
# Privileges URLS
|
72
|
+
LIST_PRIVILEGES_URL = "https://api.%s.onelogin.com/api/1/privileges"
|
73
|
+
CREATE_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges"
|
74
|
+
UPDATE_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s"
|
75
|
+
GET_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s"
|
76
|
+
DELETE_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s"
|
77
|
+
GET_ROLES_ASSIGNED_TO_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s/roles"
|
78
|
+
ASSIGN_ROLES_TO_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s/roles"
|
79
|
+
REMOVE_ROLE_FROM_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s/roles/%s"
|
80
|
+
GET_USERS_ASSIGNED_TO_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s/users"
|
81
|
+
ASSIGN_USERS_TO_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s/users"
|
82
|
+
REMOVE_USER_FROM_PRIVILEGE_URL = "https://api.%s.onelogin.com/api/1/privileges/%s/users/%s"
|
83
|
+
VALID_ACTIONS = [
|
84
|
+
"apps:List",
|
85
|
+
"apps:Get",
|
86
|
+
"apps:Create",
|
87
|
+
"apps:Update",
|
88
|
+
"apps:Delete",
|
89
|
+
"apps:ManageRoles",
|
90
|
+
"apps:ManageUsers",
|
91
|
+
"directories:List",
|
92
|
+
"directories:Get",
|
93
|
+
"directories:Create",
|
94
|
+
"directories:Update",
|
95
|
+
"directories:Delete",
|
96
|
+
"directories:SyncUsers",
|
97
|
+
"directories:RefreshSchema",
|
98
|
+
"events:List",
|
99
|
+
"events:Get",
|
100
|
+
"mappings:List",
|
101
|
+
"mappings:Get",
|
102
|
+
"mappings:Create",
|
103
|
+
"mappings:Update",
|
104
|
+
"mappings:Delete",
|
105
|
+
"mappings:ReapplyAll",
|
106
|
+
"policies:List",
|
107
|
+
"policies:user:Get",
|
108
|
+
"policies:user:Create",
|
109
|
+
"policies:user:Update",
|
110
|
+
"policies:user:Delete",
|
111
|
+
"policies:app:Get",
|
112
|
+
"policies:app:Create",
|
113
|
+
"policies:app:Update",
|
114
|
+
"policies:app:Delete",
|
115
|
+
"privileges:List",
|
116
|
+
"privileges:Get",
|
117
|
+
"privileges:Create",
|
118
|
+
"privileges:Update",
|
119
|
+
"privileges:Delete",
|
120
|
+
"privileges:ListUsers",
|
121
|
+
"privileges:ListRoles",
|
122
|
+
"privileges:ManageUsers",
|
123
|
+
"privileges:ManageRoles",
|
124
|
+
"reports:List",
|
125
|
+
"reports:Get",
|
126
|
+
"reports:Create",
|
127
|
+
"reports:Update",
|
128
|
+
"reports:Delete",
|
129
|
+
"reports:Run",
|
130
|
+
"roles:List",
|
131
|
+
"roles:Get",
|
132
|
+
"roles:Create",
|
133
|
+
"roles:Update",
|
134
|
+
"roles:Delete",
|
135
|
+
"roles:ManageUsers",
|
136
|
+
"roles:ManageApps",
|
137
|
+
"trustedidp:List",
|
138
|
+
"trustedidp:Get",
|
139
|
+
"trustedidp:Create",
|
140
|
+
"trustedidp:Update",
|
141
|
+
"trustedidp:Delete",
|
142
|
+
"users:List",
|
143
|
+
"users:Get",
|
144
|
+
"users:Create",
|
145
|
+
"users:Update",
|
146
|
+
"users:Delete",
|
147
|
+
"users:Unlock",
|
148
|
+
"users:ResetPassword",
|
149
|
+
"users:ForceLogout",
|
150
|
+
"users:Invite",
|
151
|
+
"users:ReapplyMappings",
|
152
|
+
"users:ManageRoles",
|
153
|
+
"users:ManageApps",
|
154
|
+
"users:GenerateTempMfaToken"
|
155
|
+
]
|
70
156
|
end
|
71
157
|
end
|
72
158
|
end
|
@@ -5,18 +5,24 @@ module OneLogin
|
|
5
5
|
def extract_error_message_from_response(response)
|
6
6
|
message = ''
|
7
7
|
content = JSON.parse(response.body)
|
8
|
-
if content
|
9
|
-
|
10
|
-
|
11
|
-
if status
|
12
|
-
if status['message'].
|
13
|
-
|
8
|
+
if content
|
9
|
+
if content.has_key?('status')
|
10
|
+
status = content['status']
|
11
|
+
if status.has_key?('message')
|
12
|
+
if status['message'].instance_of?(Hash)
|
13
|
+
if status['message'].has_key?('description')
|
14
|
+
message = status['message']['description']
|
15
|
+
end
|
16
|
+
else
|
17
|
+
message = status['message']
|
14
18
|
end
|
15
|
-
|
16
|
-
message = status['
|
19
|
+
elsif status.has_key?('type')
|
20
|
+
message = status['type']
|
17
21
|
end
|
18
|
-
elsif
|
19
|
-
message =
|
22
|
+
elsif content.has_key?('message')
|
23
|
+
message = content['message']
|
24
|
+
elsif content.has_key?('name')
|
25
|
+
message = content['name']
|
20
26
|
end
|
21
27
|
end
|
22
28
|
message
|
@@ -36,6 +42,14 @@ module OneLogin
|
|
36
42
|
attribute
|
37
43
|
end
|
38
44
|
|
45
|
+
def extract_status_code_from_response(response)
|
46
|
+
status_code = ''
|
47
|
+
content = JSON.parse(response.body)
|
48
|
+
if content && content.has_key?('statusCode')
|
49
|
+
status_code = content['statusCode']
|
50
|
+
end
|
51
|
+
status_code
|
52
|
+
end
|
39
53
|
end
|
40
54
|
end
|
41
55
|
end
|
data/lib/onelogin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onelogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OneLogin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -228,11 +228,13 @@ files:
|
|
228
228
|
- lib/onelogin/api/models/mfa.rb
|
229
229
|
- lib/onelogin/api/models/onelogin_token.rb
|
230
230
|
- lib/onelogin/api/models/otp_device.rb
|
231
|
+
- lib/onelogin/api/models/privilege.rb
|
231
232
|
- lib/onelogin/api/models/rate_limit.rb
|
232
233
|
- lib/onelogin/api/models/role.rb
|
233
234
|
- lib/onelogin/api/models/saml_endpoint_response.rb
|
234
235
|
- lib/onelogin/api/models/session_token_info.rb
|
235
236
|
- lib/onelogin/api/models/session_token_mfa_info.rb
|
237
|
+
- lib/onelogin/api/models/statement.rb
|
236
238
|
- lib/onelogin/api/models/user.rb
|
237
239
|
- lib/onelogin/api/models/user_data.rb
|
238
240
|
- lib/onelogin/api/models/user_metadata.rb
|
@@ -263,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
265
|
version: '0'
|
264
266
|
requirements: []
|
265
267
|
rubyforge_project: http://www.rubygems.org/gems/onelogin-ruby-sdk
|
266
|
-
rubygems_version: 2.
|
268
|
+
rubygems_version: 2.2.2
|
267
269
|
signing_key:
|
268
270
|
specification_version: 4
|
269
271
|
summary: OneLogin's Ruby SDK.
|