onelogin 1.5.0 → 1.7.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 +5 -5
- data/.github/workflows/git-secrets-public.yml +55 -0
- data/.github/workflows/test.yml +25 -0
- data/.gitignore +1 -0
- data/README.md +61 -2
- data/examples/Gemfile.lock +10 -6
- data/examples/another-get-all-login-events-of-last-day-to-csv.rb +141 -0
- data/examples/events-to-csv.rb +3 -3
- data/examples/get-all-login-events-of-last-day-to-csv.rb +88 -0
- data/examples/rails-custom-login-page/Gemfile +2 -2
- data/examples/rails-custom-login-page/Gemfile.lock +20 -16
- data/examples/rails-custom-login-page/README.md +32 -0
- data/examples/rails-custom-login-page/app/controllers/home_controller.rb +1 -0
- data/examples/rails-custom-login-page/app/views/dashboard/index.html.erb +2 -9
- data/examples/rails-custom-login-page/app/views/home/index.html.erb +71 -8
- data/examples/rails-custom-login-page/config/initializers/onelogin.rb +3 -1
- data/examples/rails-custom-login-page/config/secrets.yml.sample +2 -0
- data/lib/onelogin/api/client.rb +646 -18
- data/lib/onelogin/api/cursor.rb +4 -3
- data/lib/onelogin/api/models/connector_basic.rb +20 -0
- data/lib/onelogin/api/models/event.rb +1 -1
- data/lib/onelogin/api/models/onelogin_app.rb +46 -6
- data/lib/onelogin/api/models/onelogin_app_basic.rb +51 -0
- data/lib/onelogin/api/models/onelogin_app_v1.rb +22 -0
- data/lib/onelogin/api/models/user.rb +1 -1
- data/lib/onelogin/api/models.rb +3 -0
- data/lib/onelogin/api/util/constants.rb +15 -1
- data/lib/onelogin/version.rb +1 -1
- data/onelogin.gemspec +3 -2
- metadata +31 -11
data/lib/onelogin/api/client.rb
CHANGED
|
@@ -26,6 +26,7 @@ module OneLogin
|
|
|
26
26
|
Nokogiri::XML::ParseOptions::NONET
|
|
27
27
|
|
|
28
28
|
DEFAULT_USER_AGENT = "onelogin-ruby-sdk v#{OneLogin::VERSION}".freeze
|
|
29
|
+
DEFAULT_TOKEN_EXPIRATION_BUFFER = 30 # seconds
|
|
29
30
|
|
|
30
31
|
# Create a new instance of the Client.
|
|
31
32
|
#
|
|
@@ -38,6 +39,7 @@ module OneLogin
|
|
|
38
39
|
@client_secret = options[:client_secret]
|
|
39
40
|
@region = options[:region] || 'us'
|
|
40
41
|
@max_results = options[:max_results] || 1000
|
|
42
|
+
@token_expiration_buffer = normalize_expiration_buffer(options[:token_expiration_buffer])
|
|
41
43
|
|
|
42
44
|
if options[:timeout] and defined? self.class.default_timeout
|
|
43
45
|
self.class.default_timeout options[:timeout]
|
|
@@ -47,6 +49,8 @@ module OneLogin
|
|
|
47
49
|
self.class.http_proxy options[:proxy_host], options[:proxy_port], options[:proxy_user], options[:proxy_pass]
|
|
48
50
|
end
|
|
49
51
|
|
|
52
|
+
self.class.default_options.update(verify: false)
|
|
53
|
+
|
|
50
54
|
validate_config
|
|
51
55
|
|
|
52
56
|
@user_agent = DEFAULT_USER_AGENT
|
|
@@ -56,6 +60,29 @@ module OneLogin
|
|
|
56
60
|
raise ArgumentError, 'client_id & client_secret are required' unless @client_id && @client_secret
|
|
57
61
|
end
|
|
58
62
|
|
|
63
|
+
# Coerce the configured refresh buffer into a non-negative Integer.
|
|
64
|
+
#
|
|
65
|
+
# ENV-backed configs hand this over as a String, and a negative buffer
|
|
66
|
+
# would move the refresh point past the token's real expiry - which is the
|
|
67
|
+
# 401 this buffer exists to prevent - so reject both loudly.
|
|
68
|
+
#
|
|
69
|
+
def normalize_expiration_buffer(value)
|
|
70
|
+
return DEFAULT_TOKEN_EXPIRATION_BUFFER if value.nil?
|
|
71
|
+
|
|
72
|
+
buffer = begin
|
|
73
|
+
Integer(value)
|
|
74
|
+
rescue ArgumentError, TypeError
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if buffer.nil? || buffer < 0
|
|
79
|
+
raise ArgumentError, "token_expiration_buffer must be a non-negative integer, got #{value.inspect}"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
buffer
|
|
83
|
+
end
|
|
84
|
+
private :normalize_expiration_buffer
|
|
85
|
+
|
|
59
86
|
# Clean any previous error registered at the client.
|
|
60
87
|
#
|
|
61
88
|
def clean_error
|
|
@@ -64,15 +91,26 @@ module OneLogin
|
|
|
64
91
|
@error_attribute = nil
|
|
65
92
|
end
|
|
66
93
|
|
|
94
|
+
# Whether the current access token should be considered expired.
|
|
95
|
+
#
|
|
96
|
+
# Treats the token as expired `token_expiration_buffer` seconds early so a
|
|
97
|
+
# token that would lapse while a request is in flight is refreshed first.
|
|
98
|
+
#
|
|
99
|
+
# @return [Boolean] true when there is no expiration recorded or the token
|
|
100
|
+
# is inside the refresh buffer.
|
|
101
|
+
#
|
|
67
102
|
def expired?
|
|
68
|
-
|
|
103
|
+
return true if @expiration.nil?
|
|
104
|
+
Time.now.utc > (@expiration - @token_expiration_buffer)
|
|
69
105
|
end
|
|
70
106
|
|
|
71
107
|
def prepare_token
|
|
72
108
|
if @access_token.nil?
|
|
73
109
|
access_token
|
|
74
110
|
elsif expired?
|
|
75
|
-
|
|
111
|
+
# Fall back to a brand new token if the refresh grant fails, otherwise
|
|
112
|
+
# the stale token is reused and the request comes back 401.
|
|
113
|
+
regenerate_token || access_token
|
|
76
114
|
end
|
|
77
115
|
end
|
|
78
116
|
|
|
@@ -342,7 +380,7 @@ module OneLogin
|
|
|
342
380
|
params: params
|
|
343
381
|
}
|
|
344
382
|
|
|
345
|
-
return Cursor.new(self
|
|
383
|
+
return Cursor.new(self, url_for(GET_USERS_URL), options)
|
|
346
384
|
|
|
347
385
|
rescue Exception => e
|
|
348
386
|
@error = '500'
|
|
@@ -364,6 +402,12 @@ module OneLogin
|
|
|
364
402
|
prepare_token
|
|
365
403
|
|
|
366
404
|
begin
|
|
405
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
406
|
+
@error = '400'
|
|
407
|
+
@error_description = "user_id is required"
|
|
408
|
+
@error_attribute = "user_id"
|
|
409
|
+
return
|
|
410
|
+
end
|
|
367
411
|
|
|
368
412
|
url = url_for(GET_USER_URL, user_id)
|
|
369
413
|
|
|
@@ -401,13 +445,20 @@ module OneLogin
|
|
|
401
445
|
prepare_token
|
|
402
446
|
|
|
403
447
|
begin
|
|
448
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
449
|
+
@error = '400'
|
|
450
|
+
@error_description = "user_id is required"
|
|
451
|
+
@error_attribute = "user_id"
|
|
452
|
+
return
|
|
453
|
+
end
|
|
454
|
+
|
|
404
455
|
options = {
|
|
405
456
|
model: OneLogin::Api::Models::App,
|
|
406
457
|
headers: authorized_headers,
|
|
407
458
|
max_results: @max_results
|
|
408
459
|
}
|
|
409
460
|
|
|
410
|
-
return Cursor.new(self
|
|
461
|
+
return Cursor.new(self, url_for(GET_APPS_FOR_USER_URL, user_id), options)
|
|
411
462
|
|
|
412
463
|
rescue Exception => e
|
|
413
464
|
@error = '500'
|
|
@@ -429,6 +480,13 @@ module OneLogin
|
|
|
429
480
|
prepare_token
|
|
430
481
|
|
|
431
482
|
begin
|
|
483
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
484
|
+
@error = '400'
|
|
485
|
+
@error_description = "user_id is required"
|
|
486
|
+
@error_attribute = "user_id"
|
|
487
|
+
return
|
|
488
|
+
end
|
|
489
|
+
|
|
432
490
|
url = url_for(GET_ROLES_FOR_USER_URL, user_id)
|
|
433
491
|
|
|
434
492
|
response = self.class.get(
|
|
@@ -552,6 +610,13 @@ module OneLogin
|
|
|
552
610
|
prepare_token
|
|
553
611
|
|
|
554
612
|
begin
|
|
613
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
614
|
+
@error = '400'
|
|
615
|
+
@error_description = "user_id is required"
|
|
616
|
+
@error_attribute = "user_id"
|
|
617
|
+
return
|
|
618
|
+
end
|
|
619
|
+
|
|
555
620
|
url = url_for(UPDATE_USER_URL, user_id)
|
|
556
621
|
|
|
557
622
|
response = self.class.put(
|
|
@@ -591,6 +656,13 @@ module OneLogin
|
|
|
591
656
|
prepare_token
|
|
592
657
|
|
|
593
658
|
begin
|
|
659
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
660
|
+
@error = '400'
|
|
661
|
+
@error_description = "user_id is required"
|
|
662
|
+
@error_attribute = "user_id"
|
|
663
|
+
return
|
|
664
|
+
end
|
|
665
|
+
|
|
594
666
|
url = url_for(ADD_ROLE_TO_USER_URL, user_id)
|
|
595
667
|
|
|
596
668
|
data = {
|
|
@@ -631,6 +703,13 @@ module OneLogin
|
|
|
631
703
|
prepare_token
|
|
632
704
|
|
|
633
705
|
begin
|
|
706
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
707
|
+
@error = '400'
|
|
708
|
+
@error_description = "user_id is required"
|
|
709
|
+
@error_attribute = "user_id"
|
|
710
|
+
return
|
|
711
|
+
end
|
|
712
|
+
|
|
634
713
|
url = url_for(DELETE_ROLE_TO_USER_URL, user_id)
|
|
635
714
|
|
|
636
715
|
data = {
|
|
@@ -673,6 +752,13 @@ module OneLogin
|
|
|
673
752
|
prepare_token
|
|
674
753
|
|
|
675
754
|
begin
|
|
755
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
756
|
+
@error = '400'
|
|
757
|
+
@error_description = "user_id is required"
|
|
758
|
+
@error_attribute = "user_id"
|
|
759
|
+
return
|
|
760
|
+
end
|
|
761
|
+
|
|
676
762
|
url = url_for(SET_PW_CLEARTEXT, user_id)
|
|
677
763
|
|
|
678
764
|
data = {
|
|
@@ -718,6 +804,13 @@ module OneLogin
|
|
|
718
804
|
prepare_token
|
|
719
805
|
|
|
720
806
|
begin
|
|
807
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
808
|
+
@error = '400'
|
|
809
|
+
@error_description = "user_id is required"
|
|
810
|
+
@error_attribute = "user_id"
|
|
811
|
+
return
|
|
812
|
+
end
|
|
813
|
+
|
|
721
814
|
url = url_for(SET_PW_SALT, user_id)
|
|
722
815
|
|
|
723
816
|
data = {
|
|
@@ -764,6 +857,13 @@ module OneLogin
|
|
|
764
857
|
prepare_token
|
|
765
858
|
|
|
766
859
|
begin
|
|
860
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
861
|
+
@error = '400'
|
|
862
|
+
@error_description = "user_id is required"
|
|
863
|
+
@error_attribute = "user_id"
|
|
864
|
+
return
|
|
865
|
+
end
|
|
866
|
+
|
|
767
867
|
url = url_for(SET_USER_STATE_URL, user_id)
|
|
768
868
|
|
|
769
869
|
data = {
|
|
@@ -804,6 +904,13 @@ module OneLogin
|
|
|
804
904
|
prepare_token
|
|
805
905
|
|
|
806
906
|
begin
|
|
907
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
908
|
+
@error = '400'
|
|
909
|
+
@error_description = "user_id is required"
|
|
910
|
+
@error_attribute = "user_id"
|
|
911
|
+
return
|
|
912
|
+
end
|
|
913
|
+
|
|
807
914
|
url = url_for(SET_CUSTOM_ATTRIBUTE_TO_USER_URL, user_id)
|
|
808
915
|
|
|
809
916
|
data = {
|
|
@@ -843,6 +950,13 @@ module OneLogin
|
|
|
843
950
|
prepare_token
|
|
844
951
|
|
|
845
952
|
begin
|
|
953
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
954
|
+
@error = '400'
|
|
955
|
+
@error_description = "user_id is required"
|
|
956
|
+
@error_attribute = "user_id"
|
|
957
|
+
return
|
|
958
|
+
end
|
|
959
|
+
|
|
846
960
|
url = url_for(LOG_USER_OUT_URL, user_id)
|
|
847
961
|
|
|
848
962
|
response = self.class.put(
|
|
@@ -880,6 +994,13 @@ module OneLogin
|
|
|
880
994
|
prepare_token
|
|
881
995
|
|
|
882
996
|
begin
|
|
997
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
998
|
+
@error = '400'
|
|
999
|
+
@error_description = "user_id is required"
|
|
1000
|
+
@error_attribute = "user_id"
|
|
1001
|
+
return
|
|
1002
|
+
end
|
|
1003
|
+
|
|
883
1004
|
url = url_for(LOCK_USER_URL, user_id)
|
|
884
1005
|
|
|
885
1006
|
data = {
|
|
@@ -919,6 +1040,13 @@ module OneLogin
|
|
|
919
1040
|
prepare_token
|
|
920
1041
|
|
|
921
1042
|
begin
|
|
1043
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
1044
|
+
@error = '400'
|
|
1045
|
+
@error_description = "user_id is required"
|
|
1046
|
+
@error_attribute = "user_id"
|
|
1047
|
+
return
|
|
1048
|
+
end
|
|
1049
|
+
|
|
922
1050
|
url = url_for(DELETE_USER_URL, user_id)
|
|
923
1051
|
|
|
924
1052
|
response = self.class.delete(
|
|
@@ -952,11 +1080,18 @@ module OneLogin
|
|
|
952
1080
|
# @return [MFAToken] if the action succeed
|
|
953
1081
|
#
|
|
954
1082
|
# @see {https://developers.onelogin.com/api-docs/1/multi-factor-authentication/generate-mfa-token Generate MFA Token documentation}
|
|
955
|
-
def generate_mfa_token(user_id, expires_in=259200, reusable=
|
|
1083
|
+
def generate_mfa_token(user_id, expires_in=259200, reusable=false)
|
|
956
1084
|
clean_error
|
|
957
1085
|
prepare_token
|
|
958
1086
|
|
|
959
1087
|
begin
|
|
1088
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
1089
|
+
@error = '400'
|
|
1090
|
+
@error_description = "user_id is required"
|
|
1091
|
+
@error_attribute = "user_id"
|
|
1092
|
+
return
|
|
1093
|
+
end
|
|
1094
|
+
|
|
960
1095
|
url = url_for(GENERATE_MFA_TOKEN_URL, user_id)
|
|
961
1096
|
|
|
962
1097
|
data = {
|
|
@@ -1051,6 +1186,13 @@ module OneLogin
|
|
|
1051
1186
|
prepare_token
|
|
1052
1187
|
|
|
1053
1188
|
begin
|
|
1189
|
+
if device_id.nil? || device_id.to_s.empty?
|
|
1190
|
+
@error = '400'
|
|
1191
|
+
@error_description = "device_id is required"
|
|
1192
|
+
@error_attribute = "device_id"
|
|
1193
|
+
return
|
|
1194
|
+
end
|
|
1195
|
+
|
|
1054
1196
|
url = url_for(GET_TOKEN_VERIFY_FACTOR)
|
|
1055
1197
|
|
|
1056
1198
|
data = {
|
|
@@ -1088,31 +1230,76 @@ module OneLogin
|
|
|
1088
1230
|
nil
|
|
1089
1231
|
end
|
|
1090
1232
|
|
|
1233
|
+
###############################
|
|
1234
|
+
# Onelogin Connectors Methods #
|
|
1235
|
+
###############################
|
|
1236
|
+
|
|
1237
|
+
# Gets a list of Connector resources.
|
|
1238
|
+
#
|
|
1239
|
+
# @param params [Hash] Parameters to filter the result of the list
|
|
1240
|
+
#
|
|
1241
|
+
# @return [Array] list of Connector objects
|
|
1242
|
+
#
|
|
1243
|
+
# @see {https://developers.onelogin.com/api-docs/1/connectors/list-connectors List Connectors documentation}
|
|
1244
|
+
def get_connectors(params = {})
|
|
1245
|
+
clean_error
|
|
1246
|
+
prepare_token
|
|
1247
|
+
|
|
1248
|
+
begin
|
|
1249
|
+
url = url_for(GET_CONNECTORS_URL)
|
|
1250
|
+
|
|
1251
|
+
connectors = []
|
|
1252
|
+
response = self.class.get(
|
|
1253
|
+
url,
|
|
1254
|
+
headers: authorized_headers,
|
|
1255
|
+
query: params
|
|
1256
|
+
)
|
|
1257
|
+
|
|
1258
|
+
if response.code == 200
|
|
1259
|
+
json_data = JSON.parse(response.body)
|
|
1260
|
+
if !json_data.empty?
|
|
1261
|
+
json_data.each do |data|
|
|
1262
|
+
pp data
|
|
1263
|
+
connectors << OneLogin::Api::Models::ConnectorBasic.new(data)
|
|
1264
|
+
end
|
|
1265
|
+
end
|
|
1266
|
+
return connectors
|
|
1267
|
+
else
|
|
1268
|
+
@error = extract_status_code_from_response(response)
|
|
1269
|
+
@error_description = extract_error_message_from_response(response)
|
|
1270
|
+
end
|
|
1271
|
+
rescue Exception => e
|
|
1272
|
+
@error = '500'
|
|
1273
|
+
@error_description = e.message
|
|
1274
|
+
end
|
|
1275
|
+
|
|
1276
|
+
nil
|
|
1277
|
+
end
|
|
1091
1278
|
|
|
1092
1279
|
#########################
|
|
1093
1280
|
# Onelogin Apps Methods #
|
|
1094
1281
|
#########################
|
|
1095
1282
|
|
|
1096
|
-
# Gets a list of
|
|
1283
|
+
# Gets a list of OneLoginAppV1 resources. (if no limit provided, by default get 50 elements)
|
|
1097
1284
|
#
|
|
1098
1285
|
# @param params [Hash] Parameters to filter the result of the list
|
|
1099
1286
|
#
|
|
1100
|
-
# @return [Array] list of
|
|
1287
|
+
# @return [Array] list of OneLoginAppV1 objects
|
|
1101
1288
|
#
|
|
1102
1289
|
# @see {https://developers.onelogin.com/api-docs/1/apps/get-apps Get Apps documentation}
|
|
1103
|
-
def
|
|
1290
|
+
def get_apps_v1(params = {})
|
|
1104
1291
|
clean_error
|
|
1105
1292
|
prepare_token
|
|
1106
1293
|
|
|
1107
1294
|
begin
|
|
1108
1295
|
options = {
|
|
1109
|
-
model: OneLogin::Api::Models::
|
|
1296
|
+
model: OneLogin::Api::Models::OneLoginAppV1,
|
|
1110
1297
|
headers: authorized_headers,
|
|
1111
1298
|
max_results: @max_results,
|
|
1112
1299
|
params: params
|
|
1113
1300
|
}
|
|
1114
1301
|
|
|
1115
|
-
return Cursor.new(self
|
|
1302
|
+
return Cursor.new(self, url_for(GET_APPS_URL_V1), options)
|
|
1116
1303
|
|
|
1117
1304
|
rescue Exception => e
|
|
1118
1305
|
@error = '500'
|
|
@@ -1122,6 +1309,272 @@ module OneLogin
|
|
|
1122
1309
|
nil
|
|
1123
1310
|
end
|
|
1124
1311
|
|
|
1312
|
+
# Gets a list of OneLoginAppBasic resources.
|
|
1313
|
+
#
|
|
1314
|
+
# @param params [Hash] Parameters to filter the result of the list
|
|
1315
|
+
#
|
|
1316
|
+
# @return [Array] list of OneLoginAppBasic objects
|
|
1317
|
+
#
|
|
1318
|
+
# @see {https://developers.onelogin.com/api-docs/1/apps/list-apps Get Apps documentation}
|
|
1319
|
+
def get_apps(params = {})
|
|
1320
|
+
clean_error
|
|
1321
|
+
prepare_token
|
|
1322
|
+
|
|
1323
|
+
begin
|
|
1324
|
+
url = url_for(GET_APPS_URL)
|
|
1325
|
+
|
|
1326
|
+
apps = []
|
|
1327
|
+
response = self.class.get(
|
|
1328
|
+
url,
|
|
1329
|
+
headers: authorized_headers,
|
|
1330
|
+
query: params
|
|
1331
|
+
)
|
|
1332
|
+
|
|
1333
|
+
if response.code == 200
|
|
1334
|
+
json_data = JSON.parse(response.body)
|
|
1335
|
+
if !json_data.empty?
|
|
1336
|
+
json_data.each do |data|
|
|
1337
|
+
apps << OneLogin::Api::Models::OneLoginAppBasic.new(data)
|
|
1338
|
+
end
|
|
1339
|
+
end
|
|
1340
|
+
return apps
|
|
1341
|
+
else
|
|
1342
|
+
@error = extract_status_code_from_response(response)
|
|
1343
|
+
@error_description = extract_error_message_from_response(response)
|
|
1344
|
+
end
|
|
1345
|
+
rescue Exception => e
|
|
1346
|
+
@error = '500'
|
|
1347
|
+
@error_description = e.message
|
|
1348
|
+
end
|
|
1349
|
+
|
|
1350
|
+
nil
|
|
1351
|
+
end
|
|
1352
|
+
|
|
1353
|
+
# Creates an app
|
|
1354
|
+
#
|
|
1355
|
+
# @param app_params [Hash] App data (name, visible, policy_id, is_available, parameters, allow_assumed_signin,
|
|
1356
|
+
# configuration, notes, description, provisioning,
|
|
1357
|
+
# connector_id, auth_method, tab_id)
|
|
1358
|
+
#
|
|
1359
|
+
# @return [OneLoginApp] the created app
|
|
1360
|
+
#
|
|
1361
|
+
# @see {https://developers.onelogin.com/api-docs/1/apps/create-app Create App documentation}
|
|
1362
|
+
def create_app(app_params)
|
|
1363
|
+
clean_error
|
|
1364
|
+
prepare_token
|
|
1365
|
+
|
|
1366
|
+
begin
|
|
1367
|
+
url = url_for(CREATE_APP_URL)
|
|
1368
|
+
|
|
1369
|
+
unless app_params.has_key?('connector_id') || app_params['connector_id'].to_s.empty?
|
|
1370
|
+
@error = '400'
|
|
1371
|
+
@error_description = "connector_id is required"
|
|
1372
|
+
@error_attribute = "connector_id"
|
|
1373
|
+
return
|
|
1374
|
+
end
|
|
1375
|
+
|
|
1376
|
+
response = self.class.post(
|
|
1377
|
+
url,
|
|
1378
|
+
headers: authorized_headers,
|
|
1379
|
+
body: app_params.to_json
|
|
1380
|
+
)
|
|
1381
|
+
|
|
1382
|
+
if response.code == 201
|
|
1383
|
+
json_data = JSON.parse(response.body)
|
|
1384
|
+
if json_data && json_data.has_key?('id')
|
|
1385
|
+
return OneLogin::Api::Models::OneLoginApp.new(json_data)
|
|
1386
|
+
end
|
|
1387
|
+
else
|
|
1388
|
+
@error = extract_status_code_from_response(response)
|
|
1389
|
+
@error_description = extract_error_message_from_response(response)
|
|
1390
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
|
1391
|
+
end
|
|
1392
|
+
rescue Exception => e
|
|
1393
|
+
@error = '500'
|
|
1394
|
+
@error_description = e.message
|
|
1395
|
+
end
|
|
1396
|
+
|
|
1397
|
+
nil
|
|
1398
|
+
end
|
|
1399
|
+
|
|
1400
|
+
# Gets a OneLoginApp resource.
|
|
1401
|
+
#
|
|
1402
|
+
# @return [OneLoginApp] OneLoginApp object
|
|
1403
|
+
#
|
|
1404
|
+
# @see {https://developers.onelogin.com/api-docs/1/apps/get-app Get App documentation}
|
|
1405
|
+
def get_app(app_id)
|
|
1406
|
+
clean_error
|
|
1407
|
+
prepare_token
|
|
1408
|
+
|
|
1409
|
+
begin
|
|
1410
|
+
if app_id.nil? || app_id.to_s.empty?
|
|
1411
|
+
@error = '400'
|
|
1412
|
+
@error_description = "app_id is required"
|
|
1413
|
+
@error_attribute = "app_id"
|
|
1414
|
+
return
|
|
1415
|
+
end
|
|
1416
|
+
|
|
1417
|
+
url = url_for(GET_APP_URL, app_id)
|
|
1418
|
+
|
|
1419
|
+
response = self.class.get(
|
|
1420
|
+
url,
|
|
1421
|
+
headers: authorized_headers
|
|
1422
|
+
)
|
|
1423
|
+
|
|
1424
|
+
if response.code == 200
|
|
1425
|
+
json_data = JSON.parse(response.body)
|
|
1426
|
+
if json_data && json_data.has_key?('id')
|
|
1427
|
+
return OneLogin::Api::Models::OneLoginApp.new(json_data)
|
|
1428
|
+
end
|
|
1429
|
+
else
|
|
1430
|
+
@error = extract_status_code_from_response(response)
|
|
1431
|
+
@error_description = extract_error_message_from_response(response)
|
|
1432
|
+
end
|
|
1433
|
+
rescue Exception => e
|
|
1434
|
+
@error = '500'
|
|
1435
|
+
@error_description = e.message
|
|
1436
|
+
end
|
|
1437
|
+
|
|
1438
|
+
nil
|
|
1439
|
+
end
|
|
1440
|
+
|
|
1441
|
+
# Updates an app
|
|
1442
|
+
#
|
|
1443
|
+
# @param app_id [Integer] Id of the app
|
|
1444
|
+
# @param app_params [Hash] App data (name, visible, policy_id, is_available, parameters, allow_assumed_signin,
|
|
1445
|
+
# configuration, notes, description, provisioning,
|
|
1446
|
+
# connector_id, auth_method, tab_id)
|
|
1447
|
+
#
|
|
1448
|
+
# @return [User] the modified user
|
|
1449
|
+
#
|
|
1450
|
+
# @see {https://developers.onelogin.com/api-docs/1/apps/update-app Update App by ID documentation}
|
|
1451
|
+
def update_app(app_id, app_params)
|
|
1452
|
+
clean_error
|
|
1453
|
+
prepare_token
|
|
1454
|
+
|
|
1455
|
+
begin
|
|
1456
|
+
if app_id.nil? || app_id.to_s.empty?
|
|
1457
|
+
@error = '400'
|
|
1458
|
+
@error_description = "app_id is required"
|
|
1459
|
+
@error_attribute = "app_id"
|
|
1460
|
+
return
|
|
1461
|
+
end
|
|
1462
|
+
|
|
1463
|
+
url = url_for(UPDATE_APP_URL, app_id)
|
|
1464
|
+
|
|
1465
|
+
response = self.class.put(
|
|
1466
|
+
url,
|
|
1467
|
+
headers: authorized_headers,
|
|
1468
|
+
body: app_params.to_json
|
|
1469
|
+
)
|
|
1470
|
+
|
|
1471
|
+
if response.code == 200
|
|
1472
|
+
json_data = JSON.parse(response.body)
|
|
1473
|
+
if json_data && json_data.has_key?('id')
|
|
1474
|
+
return OneLogin::Api::Models::OneLoginApp.new(json_data)
|
|
1475
|
+
end
|
|
1476
|
+
else
|
|
1477
|
+
@error = response.code.to_s
|
|
1478
|
+
@error_description = extract_error_message_from_response(response)
|
|
1479
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
|
1480
|
+
end
|
|
1481
|
+
rescue Exception => e
|
|
1482
|
+
@error = '500'
|
|
1483
|
+
@error_description = e.message
|
|
1484
|
+
end
|
|
1485
|
+
|
|
1486
|
+
nil
|
|
1487
|
+
end
|
|
1488
|
+
|
|
1489
|
+
# Deletes an app
|
|
1490
|
+
#
|
|
1491
|
+
# @param app_id [Integer] Id of the app to be removed
|
|
1492
|
+
#
|
|
1493
|
+
# @return [Boolean] if the action succeed
|
|
1494
|
+
#
|
|
1495
|
+
# @see {https://developers.onelogin.com/api-docs/1/apps/delete-app Delete App by ID documentation}
|
|
1496
|
+
def delete_app(app_id)
|
|
1497
|
+
clean_error
|
|
1498
|
+
prepare_token
|
|
1499
|
+
|
|
1500
|
+
begin
|
|
1501
|
+
if app_id.nil? || app_id.to_s.empty?
|
|
1502
|
+
@error = '400'
|
|
1503
|
+
@error_description = "app_id is required"
|
|
1504
|
+
@error_attribute = "app_id"
|
|
1505
|
+
return
|
|
1506
|
+
end
|
|
1507
|
+
|
|
1508
|
+
url = url_for(DELETE_APP_URL, app_id)
|
|
1509
|
+
|
|
1510
|
+
response = self.class.delete(
|
|
1511
|
+
url,
|
|
1512
|
+
headers: authorized_headers
|
|
1513
|
+
)
|
|
1514
|
+
|
|
1515
|
+
if response.code == 204
|
|
1516
|
+
return true
|
|
1517
|
+
else
|
|
1518
|
+
@error = response.code.to_s
|
|
1519
|
+
@error_description = extract_error_message_from_response(response)
|
|
1520
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
|
1521
|
+
end
|
|
1522
|
+
rescue Exception => e
|
|
1523
|
+
@error = '500'
|
|
1524
|
+
@error_description = e.message
|
|
1525
|
+
end
|
|
1526
|
+
|
|
1527
|
+
false
|
|
1528
|
+
end
|
|
1529
|
+
|
|
1530
|
+
# Deletes an App Parameter
|
|
1531
|
+
#
|
|
1532
|
+
# @param app_id [Integer] Id of the app
|
|
1533
|
+
# @param parameter_id [Integer] Id of the parameter to be removed
|
|
1534
|
+
#
|
|
1535
|
+
# @return [Boolean] if the action succeed
|
|
1536
|
+
#
|
|
1537
|
+
# @see {https://developers.onelogin.com/api-docs/1/apps/delete-parameter Delete an App Parameter documentation}
|
|
1538
|
+
def delete_parameter_from_app(app_id, parameter_id)
|
|
1539
|
+
clean_error
|
|
1540
|
+
prepare_token
|
|
1541
|
+
|
|
1542
|
+
begin
|
|
1543
|
+
if app_id.nil? || app_id.to_s.empty?
|
|
1544
|
+
@error = '400'
|
|
1545
|
+
@error_description = "app_id is required"
|
|
1546
|
+
@error_attribute = "app_id"
|
|
1547
|
+
return
|
|
1548
|
+
end
|
|
1549
|
+
|
|
1550
|
+
if parameter_id.nil? || parameter_id.to_s.empty?
|
|
1551
|
+
@error = '400'
|
|
1552
|
+
@error_description = "parameter_id is required"
|
|
1553
|
+
@error_attribute = "parameter_id"
|
|
1554
|
+
return
|
|
1555
|
+
end
|
|
1556
|
+
|
|
1557
|
+
url = url_for(DELETE_APP_PARAMETER_URL, app_id, parameter_id)
|
|
1558
|
+
|
|
1559
|
+
response = self.class.delete(
|
|
1560
|
+
url,
|
|
1561
|
+
headers: authorized_headers
|
|
1562
|
+
)
|
|
1563
|
+
|
|
1564
|
+
if response.code == 204
|
|
1565
|
+
return true
|
|
1566
|
+
else
|
|
1567
|
+
@error = response.code.to_s
|
|
1568
|
+
@error_description = extract_error_message_from_response(response)
|
|
1569
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
|
1570
|
+
end
|
|
1571
|
+
rescue Exception => e
|
|
1572
|
+
@error = '500'
|
|
1573
|
+
@error_description = e.message
|
|
1574
|
+
end
|
|
1575
|
+
|
|
1576
|
+
false
|
|
1577
|
+
end
|
|
1125
1578
|
|
|
1126
1579
|
################
|
|
1127
1580
|
# Role Methods #
|
|
@@ -1146,7 +1599,7 @@ module OneLogin
|
|
|
1146
1599
|
params: params
|
|
1147
1600
|
}
|
|
1148
1601
|
|
|
1149
|
-
return Cursor.new(self
|
|
1602
|
+
return Cursor.new(self, url_for(GET_ROLES_URL), options)
|
|
1150
1603
|
|
|
1151
1604
|
rescue Exception => e
|
|
1152
1605
|
@error = '500'
|
|
@@ -1168,6 +1621,13 @@ module OneLogin
|
|
|
1168
1621
|
prepare_token
|
|
1169
1622
|
|
|
1170
1623
|
begin
|
|
1624
|
+
if role_id.nil? || role_id.to_s.empty?
|
|
1625
|
+
@error = '400'
|
|
1626
|
+
@error_description = "role_id is required"
|
|
1627
|
+
@error_attribute = "role_id"
|
|
1628
|
+
return
|
|
1629
|
+
end
|
|
1630
|
+
|
|
1171
1631
|
url = url_for(GET_ROLE_URL, role_id)
|
|
1172
1632
|
|
|
1173
1633
|
response = self.class.get(
|
|
@@ -1212,7 +1672,7 @@ module OneLogin
|
|
|
1212
1672
|
max_results: @max_results
|
|
1213
1673
|
}
|
|
1214
1674
|
|
|
1215
|
-
return Cursor.new(self
|
|
1675
|
+
return Cursor.new(self, url_for(GET_EVENT_TYPES_URL), options)
|
|
1216
1676
|
|
|
1217
1677
|
rescue Exception => e
|
|
1218
1678
|
@error = '500'
|
|
@@ -1241,7 +1701,7 @@ module OneLogin
|
|
|
1241
1701
|
params: params
|
|
1242
1702
|
}
|
|
1243
1703
|
|
|
1244
|
-
return Cursor.new(self
|
|
1704
|
+
return Cursor.new(self, url_for(GET_EVENTS_URL), options)
|
|
1245
1705
|
|
|
1246
1706
|
rescue Exception => e
|
|
1247
1707
|
@error = '500'
|
|
@@ -1263,6 +1723,13 @@ module OneLogin
|
|
|
1263
1723
|
prepare_token
|
|
1264
1724
|
|
|
1265
1725
|
begin
|
|
1726
|
+
if event_id.nil? || event_id.to_s.empty?
|
|
1727
|
+
@error = '400'
|
|
1728
|
+
@error_description = "event_id is required"
|
|
1729
|
+
@error_attribute = "event_id"
|
|
1730
|
+
return
|
|
1731
|
+
end
|
|
1732
|
+
|
|
1266
1733
|
url = url_for(GET_EVENT_URL, event_id)
|
|
1267
1734
|
|
|
1268
1735
|
response = self.class.get(
|
|
@@ -1349,7 +1816,7 @@ module OneLogin
|
|
|
1349
1816
|
params: params
|
|
1350
1817
|
}
|
|
1351
1818
|
|
|
1352
|
-
return Cursor.new(self
|
|
1819
|
+
return Cursor.new(self, url_for(GET_GROUPS_URL), options)
|
|
1353
1820
|
|
|
1354
1821
|
rescue Exception => e
|
|
1355
1822
|
@error = '500'
|
|
@@ -1371,6 +1838,13 @@ module OneLogin
|
|
|
1371
1838
|
prepare_token
|
|
1372
1839
|
|
|
1373
1840
|
begin
|
|
1841
|
+
if group_id.nil? || group_id.to_s.empty?
|
|
1842
|
+
@error = '400'
|
|
1843
|
+
@error_description = "group_id is required"
|
|
1844
|
+
@error_attribute = "group_id"
|
|
1845
|
+
return
|
|
1846
|
+
end
|
|
1847
|
+
|
|
1374
1848
|
url = url_for(GET_GROUP_URL, group_id)
|
|
1375
1849
|
|
|
1376
1850
|
response = self.class.get(
|
|
@@ -1465,6 +1939,19 @@ module OneLogin
|
|
|
1465
1939
|
prepare_token
|
|
1466
1940
|
|
|
1467
1941
|
begin
|
|
1942
|
+
if app_id.nil? || app_id.to_s.empty?
|
|
1943
|
+
@error = '400'
|
|
1944
|
+
@error_description = "app_id is required"
|
|
1945
|
+
@error_attribute = "app_id"
|
|
1946
|
+
return
|
|
1947
|
+
end
|
|
1948
|
+
|
|
1949
|
+
if device_id.nil? || device_id.to_s.empty?
|
|
1950
|
+
@error = '400'
|
|
1951
|
+
@error_description = "device_id is required"
|
|
1952
|
+
@error_attribute = "device_id"
|
|
1953
|
+
return
|
|
1954
|
+
end
|
|
1468
1955
|
|
|
1469
1956
|
if url_endpoint.nil? || url_endpoint.empty?
|
|
1470
1957
|
url = url_for(GET_SAML_VERIFY_FACTOR)
|
|
@@ -1519,6 +2006,13 @@ module OneLogin
|
|
|
1519
2006
|
prepare_token
|
|
1520
2007
|
|
|
1521
2008
|
begin
|
|
2009
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
2010
|
+
@error = '400'
|
|
2011
|
+
@error_description = "user_id is required"
|
|
2012
|
+
@error_attribute = "user_id"
|
|
2013
|
+
return
|
|
2014
|
+
end
|
|
2015
|
+
|
|
1522
2016
|
url = url_for(GET_FACTORS_URL, user_id)
|
|
1523
2017
|
|
|
1524
2018
|
response = self.class.get(
|
|
@@ -1562,6 +2056,20 @@ module OneLogin
|
|
|
1562
2056
|
prepare_token
|
|
1563
2057
|
|
|
1564
2058
|
begin
|
|
2059
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
2060
|
+
@error = '400'
|
|
2061
|
+
@error_description = "user_id is required"
|
|
2062
|
+
@error_attribute = "user_id"
|
|
2063
|
+
return
|
|
2064
|
+
end
|
|
2065
|
+
|
|
2066
|
+
if factor_id.nil? || factor_id.to_s.empty?
|
|
2067
|
+
@error = '400'
|
|
2068
|
+
@error_description = "factor_id is required"
|
|
2069
|
+
@error_attribute = "factor_id"
|
|
2070
|
+
return
|
|
2071
|
+
end
|
|
2072
|
+
|
|
1565
2073
|
url = url_for(ENROLL_FACTOR_URL, user_id)
|
|
1566
2074
|
|
|
1567
2075
|
data = {
|
|
@@ -1605,6 +2113,13 @@ module OneLogin
|
|
|
1605
2113
|
prepare_token
|
|
1606
2114
|
|
|
1607
2115
|
begin
|
|
2116
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
2117
|
+
@error = '400'
|
|
2118
|
+
@error_description = "user_id is required"
|
|
2119
|
+
@error_attribute = "user_id"
|
|
2120
|
+
return
|
|
2121
|
+
end
|
|
2122
|
+
|
|
1608
2123
|
url = url_for(GET_ENROLLED_FACTORS_URL, user_id)
|
|
1609
2124
|
|
|
1610
2125
|
response = self.class.get(
|
|
@@ -1647,6 +2162,20 @@ module OneLogin
|
|
|
1647
2162
|
prepare_token
|
|
1648
2163
|
|
|
1649
2164
|
begin
|
|
2165
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
2166
|
+
@error = '400'
|
|
2167
|
+
@error_description = "user_id is required"
|
|
2168
|
+
@error_attribute = "user_id"
|
|
2169
|
+
return
|
|
2170
|
+
end
|
|
2171
|
+
|
|
2172
|
+
if device_id.nil? || device_id.to_s.empty?
|
|
2173
|
+
@error = '400'
|
|
2174
|
+
@error_description = "device_id is required"
|
|
2175
|
+
@error_attribute = "device_id"
|
|
2176
|
+
return
|
|
2177
|
+
end
|
|
2178
|
+
|
|
1650
2179
|
url = url_for(ACTIVATE_FACTOR_URL, user_id, device_id)
|
|
1651
2180
|
|
|
1652
2181
|
response = self.class.post(
|
|
@@ -1691,6 +2220,21 @@ module OneLogin
|
|
|
1691
2220
|
prepare_token
|
|
1692
2221
|
|
|
1693
2222
|
begin
|
|
2223
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
2224
|
+
@error = '400'
|
|
2225
|
+
@error_description = "user_id is required"
|
|
2226
|
+
@error_attribute = "user_id"
|
|
2227
|
+
return
|
|
2228
|
+
end
|
|
2229
|
+
|
|
2230
|
+
if device_id.nil? || device_id.to_s.empty?
|
|
2231
|
+
@error = '400'
|
|
2232
|
+
@error_description = "device_id is required"
|
|
2233
|
+
@error_attribute = "device_id"
|
|
2234
|
+
return
|
|
2235
|
+
end
|
|
2236
|
+
|
|
2237
|
+
|
|
1694
2238
|
url = url_for(VERIFY_FACTOR_URL, user_id, device_id)
|
|
1695
2239
|
|
|
1696
2240
|
data = {
|
|
@@ -1739,6 +2283,21 @@ module OneLogin
|
|
|
1739
2283
|
prepare_token
|
|
1740
2284
|
|
|
1741
2285
|
begin
|
|
2286
|
+
|
|
2287
|
+
if user_id.nil? || user_id.to_s.empty?
|
|
2288
|
+
@error = '400'
|
|
2289
|
+
@error_description = "user_id is required"
|
|
2290
|
+
@error_attribute = "user_id"
|
|
2291
|
+
return
|
|
2292
|
+
end
|
|
2293
|
+
|
|
2294
|
+
if device_id.nil? || device_id.to_s.empty?
|
|
2295
|
+
@error = '400'
|
|
2296
|
+
@error_description = "device_id is required"
|
|
2297
|
+
@error_attribute = "device_id"
|
|
2298
|
+
return
|
|
2299
|
+
end
|
|
2300
|
+
|
|
1742
2301
|
url = url_for(REMOVE_FACTOR_URL, user_id, device_id)
|
|
1743
2302
|
|
|
1744
2303
|
response = self.class.delete(
|
|
@@ -1777,6 +2336,13 @@ module OneLogin
|
|
|
1777
2336
|
prepare_token
|
|
1778
2337
|
|
|
1779
2338
|
begin
|
|
2339
|
+
if email.nil? || email.to_s.empty?
|
|
2340
|
+
@error = '400'
|
|
2341
|
+
@error_description = "email is required"
|
|
2342
|
+
@error_attribute = "email"
|
|
2343
|
+
return
|
|
2344
|
+
end
|
|
2345
|
+
|
|
1780
2346
|
url = url_for(GENERATE_INVITE_LINK_URL)
|
|
1781
2347
|
|
|
1782
2348
|
data = {
|
|
@@ -1827,7 +2393,7 @@ module OneLogin
|
|
|
1827
2393
|
'email'=> email
|
|
1828
2394
|
}
|
|
1829
2395
|
|
|
1830
|
-
unless personal_email.nil? || personal_email.empty?
|
|
2396
|
+
unless personal_email.nil? || personal_email.to_s.empty?
|
|
1831
2397
|
data['personal_email'] = personal_email
|
|
1832
2398
|
end
|
|
1833
2399
|
|
|
@@ -2030,6 +2596,12 @@ module OneLogin
|
|
|
2030
2596
|
prepare_token
|
|
2031
2597
|
|
|
2032
2598
|
begin
|
|
2599
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2600
|
+
@error = '400'
|
|
2601
|
+
@error_description = "privilege_id is required"
|
|
2602
|
+
@error_attribute = "privilege_id"
|
|
2603
|
+
return
|
|
2604
|
+
end
|
|
2033
2605
|
|
|
2034
2606
|
url = url_for(GET_PRIVILEGE_URL, privilege_id)
|
|
2035
2607
|
|
|
@@ -2071,9 +2643,16 @@ module OneLogin
|
|
|
2071
2643
|
prepare_token
|
|
2072
2644
|
|
|
2073
2645
|
begin
|
|
2646
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2647
|
+
@error = '400'
|
|
2648
|
+
@error_description = "privilege_id is required"
|
|
2649
|
+
@error_attribute = "privilege_id"
|
|
2650
|
+
return
|
|
2651
|
+
end
|
|
2652
|
+
|
|
2074
2653
|
url = url_for(UPDATE_PRIVILEGE_URL, privilege_id)
|
|
2075
2654
|
|
|
2076
|
-
|
|
2655
|
+
statement_data = []
|
|
2077
2656
|
for statement in statements
|
|
2078
2657
|
if statement.instance_of?(OneLogin::Api::Models::Statement)
|
|
2079
2658
|
statement_data << {
|
|
@@ -2133,6 +2712,13 @@ module OneLogin
|
|
|
2133
2712
|
prepare_token
|
|
2134
2713
|
|
|
2135
2714
|
begin
|
|
2715
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2716
|
+
@error = '400'
|
|
2717
|
+
@error_description = "privilege_id is required"
|
|
2718
|
+
@error_attribute = "privilege_id"
|
|
2719
|
+
return
|
|
2720
|
+
end
|
|
2721
|
+
|
|
2136
2722
|
url = url_for(DELETE_PRIVILEGE_URL, privilege_id)
|
|
2137
2723
|
|
|
2138
2724
|
response = self.class.delete(
|
|
@@ -2166,13 +2752,20 @@ module OneLogin
|
|
|
2166
2752
|
prepare_token
|
|
2167
2753
|
|
|
2168
2754
|
begin
|
|
2755
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2756
|
+
@error = '400'
|
|
2757
|
+
@error_description = "privilege_id is required"
|
|
2758
|
+
@error_attribute = "privilege_id"
|
|
2759
|
+
return
|
|
2760
|
+
end
|
|
2761
|
+
|
|
2169
2762
|
options = {
|
|
2170
2763
|
headers: authorized_headers,
|
|
2171
2764
|
max_results: @max_results,
|
|
2172
2765
|
container: 'roles'
|
|
2173
2766
|
}
|
|
2174
2767
|
|
|
2175
|
-
return Cursor.new(self
|
|
2768
|
+
return Cursor.new(self, url_for(GET_ROLES_ASSIGNED_TO_PRIVILEGE_URL, privilege_id), options)
|
|
2176
2769
|
|
|
2177
2770
|
rescue Exception => e
|
|
2178
2771
|
@error = '500'
|
|
@@ -2195,6 +2788,13 @@ module OneLogin
|
|
|
2195
2788
|
prepare_token
|
|
2196
2789
|
|
|
2197
2790
|
begin
|
|
2791
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2792
|
+
@error = '400'
|
|
2793
|
+
@error_description = "privilege_id is required"
|
|
2794
|
+
@error_attribute = "privilege_id"
|
|
2795
|
+
return
|
|
2796
|
+
end
|
|
2797
|
+
|
|
2198
2798
|
url = url_for(ASSIGN_ROLES_TO_PRIVILEGE_URL, privilege_id)
|
|
2199
2799
|
|
|
2200
2800
|
data = {
|
|
@@ -2235,6 +2835,13 @@ module OneLogin
|
|
|
2235
2835
|
prepare_token
|
|
2236
2836
|
|
|
2237
2837
|
begin
|
|
2838
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2839
|
+
@error = '400'
|
|
2840
|
+
@error_description = "privilege_id is required"
|
|
2841
|
+
@error_attribute = "privilege_id"
|
|
2842
|
+
return
|
|
2843
|
+
end
|
|
2844
|
+
|
|
2238
2845
|
url = url_for(REMOVE_ROLE_FROM_PRIVILEGE_URL, privilege_id, role_id)
|
|
2239
2846
|
|
|
2240
2847
|
response = self.class.delete(
|
|
@@ -2268,13 +2875,20 @@ module OneLogin
|
|
|
2268
2875
|
prepare_token
|
|
2269
2876
|
|
|
2270
2877
|
begin
|
|
2878
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2879
|
+
@error = '400'
|
|
2880
|
+
@error_description = "privilege_id is required"
|
|
2881
|
+
@error_attribute = "privilege_id"
|
|
2882
|
+
return
|
|
2883
|
+
end
|
|
2884
|
+
|
|
2271
2885
|
options = {
|
|
2272
2886
|
headers: authorized_headers,
|
|
2273
2887
|
max_results: @max_results,
|
|
2274
2888
|
container: 'users'
|
|
2275
2889
|
}
|
|
2276
2890
|
|
|
2277
|
-
return Cursor.new(self
|
|
2891
|
+
return Cursor.new(self, url_for(GET_USERS_ASSIGNED_TO_PRIVILEGE_URL, privilege_id), options)
|
|
2278
2892
|
|
|
2279
2893
|
rescue Exception => e
|
|
2280
2894
|
@error = '500'
|
|
@@ -2297,6 +2911,13 @@ module OneLogin
|
|
|
2297
2911
|
prepare_token
|
|
2298
2912
|
|
|
2299
2913
|
begin
|
|
2914
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2915
|
+
@error = '400'
|
|
2916
|
+
@error_description = "privilege_id is required"
|
|
2917
|
+
@error_attribute = "privilege_id"
|
|
2918
|
+
return
|
|
2919
|
+
end
|
|
2920
|
+
|
|
2300
2921
|
url = url_for(ASSIGN_USERS_TO_PRIVILEGE_URL, privilege_id)
|
|
2301
2922
|
|
|
2302
2923
|
data = {
|
|
@@ -2336,6 +2957,13 @@ module OneLogin
|
|
|
2336
2957
|
prepare_token
|
|
2337
2958
|
|
|
2338
2959
|
begin
|
|
2960
|
+
if privilege_id.nil? || privilege_id.to_s.empty?
|
|
2961
|
+
@error = '400'
|
|
2962
|
+
@error_description = "privilege_id is required"
|
|
2963
|
+
@error_attribute = "privilege_id"
|
|
2964
|
+
return
|
|
2965
|
+
end
|
|
2966
|
+
|
|
2339
2967
|
url = url_for(REMOVE_USER_FROM_PRIVILEGE_URL, privilege_id, user_id)
|
|
2340
2968
|
|
|
2341
2969
|
response = self.class.delete(
|