onelogin 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -1
- data/examples/Gemfile.lock +3 -3
- data/examples/events-to-csv.rb +4 -4
- data/examples/last-app-user-login-to-csv.rb +71 -0
- data/lib/onelogin/api/client.rb +77 -38
- data/lib/onelogin/api/cursor.rb +2 -1
- data/lib/onelogin/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8069da07a08e3fe1e504af1a9fc63291976e91c0
|
4
|
+
data.tar.gz: f042c302a74c09a7fd1b4b7ddc7e06de2b5d3220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e57dbe81b5aed13dcac3a3eeef4fcc44daaccac3383d4e90703792100dff2e8010448e3b19b5e4b92c7c65bca0f15a68307d1a3715aa277d8cafeafb75b62f72
|
7
|
+
data.tar.gz: 57ce0509e3f806865283cbd8ca091a316cb8a16cf69d34bd25249a1d60ec5f06ec61eb17f655184251682c49ecae42259ca0d88e50089bd8c804d1a70c9a88be
|
data/README.md
CHANGED
@@ -74,6 +74,14 @@ if users.nil?
|
|
74
74
|
end
|
75
75
|
```
|
76
76
|
|
77
|
+
In some scenarios there is an attribute not provided or invalid that causes the error,
|
78
|
+
when that happens in addition to the error_description a error_attribute is available
|
79
|
+
with the name of the attribute that caused the issue. Accesible at the client like:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
client.error_attribute
|
83
|
+
```
|
84
|
+
|
77
85
|
### Authentication
|
78
86
|
|
79
87
|
By default methods call internally to `get_access_token` if there is no valid access_token. You can also get tokens etc directly if needed.
|
@@ -312,7 +320,7 @@ enroll_factor = client.enroll_factor(user_id, auth_factors.first.id, 'My Device'
|
|
312
320
|
|
313
321
|
# Get Enrolled Authentication Factors
|
314
322
|
otp_devices = client.get_enrolled_factors(user_id)
|
315
|
-
|
323
|
+
|
316
324
|
# Activate an Authentication Factor
|
317
325
|
device_id = 0000000
|
318
326
|
enrollment_response = client.activate_factor(user_id, device_id)
|
@@ -334,6 +342,26 @@ embed_token = "30e256c101cd0d2e731de1ec222e93c4be8a1572"
|
|
334
342
|
apps = client.get_embed_apps("30e256c101cd0d2e731de1ec222e93c4be8a1572", "user@example.com")
|
335
343
|
```
|
336
344
|
|
345
|
+
## Proxy Servers
|
346
|
+
If you're stuck behind a proxy then you can still use this SDK by providing at a minimum the
|
347
|
+
host address of your proxy server.
|
348
|
+
|
349
|
+
```ruby
|
350
|
+
client = OneLogin::Api::Client.new(
|
351
|
+
client_id: 'some-client-id',
|
352
|
+
client_secret:'some-client-secret',
|
353
|
+
region: 'us',
|
354
|
+
proxy_host: 'https://blah.com',
|
355
|
+
proxy_port: '8080',
|
356
|
+
proxy_user: 'username',
|
357
|
+
proxy_pass: 'password'
|
358
|
+
)
|
359
|
+
```
|
360
|
+
|
361
|
+
* `proxy_host` - required, the host address of your proxy server
|
362
|
+
* `proxy_port` - optional, the port number of your proxy server
|
363
|
+
* `proxy_user` - optional, the username for your proxy server
|
364
|
+
* `proxy_pass` - optional, the password for your proxy server
|
337
365
|
|
338
366
|
## Development
|
339
367
|
|
data/examples/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
httparty (0.16.
|
4
|
+
httparty (0.16.2)
|
5
5
|
multi_xml (>= 0.5.2)
|
6
6
|
mini_portile2 (2.3.0)
|
7
7
|
multi_xml (0.6.0)
|
8
|
-
nokogiri (1.8.
|
8
|
+
nokogiri (1.8.4)
|
9
9
|
mini_portile2 (~> 2.3.0)
|
10
|
-
onelogin (1.
|
10
|
+
onelogin (1.2.1)
|
11
11
|
httparty (>= 0.13.7)
|
12
12
|
nokogiri (>= 1.6.3.1)
|
13
13
|
|
data/examples/events-to-csv.rb
CHANGED
@@ -24,10 +24,10 @@ OptionParser.new do |opts|
|
|
24
24
|
options[:since] = s.iso8601
|
25
25
|
end
|
26
26
|
|
27
|
-
opts.on("-lLAST", "--LAST=LAST",
|
27
|
+
opts.on("-lLAST", "--LAST=LAST", Integer, "Events since this many days ago") do |d|
|
28
28
|
now = Date.today
|
29
29
|
days_ago = (now - d)
|
30
|
-
options[:since] = days_ago.
|
30
|
+
options[:since] = days_ago.strftime('%Y-%m-%dT%H:%M:%SZ')
|
31
31
|
end
|
32
32
|
|
33
33
|
opts.on("-uUNTIL", "--UNTIL=UNTIL", Time, "Events before this date") do |u|
|
@@ -42,12 +42,12 @@ OptionParser.new do |opts|
|
|
42
42
|
options[:event_type_id] = t
|
43
43
|
end
|
44
44
|
|
45
|
-
opts.on("-
|
45
|
+
opts.on("-uUSER", "--user=USER", Integer, "Filter by user id") do |u|
|
46
46
|
options[:user_id] = u
|
47
47
|
end
|
48
48
|
|
49
49
|
# Sort direction is done by adding a + or - before the field name that you want to sort on
|
50
|
-
opts.on("-
|
50
|
+
opts.on("-zSORT", "--sort=SORT", String, "Sort by this field") do |s|
|
51
51
|
options[:sort] = s
|
52
52
|
end
|
53
53
|
end.parse!
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'onelogin'
|
2
|
+
require 'optparse'
|
3
|
+
require 'optparse/time'
|
4
|
+
|
5
|
+
#
|
6
|
+
# This generates a report listing the last login date for all users who have logged into a specified app in the last x days.
|
7
|
+
#
|
8
|
+
# Usage:
|
9
|
+
# 1. Set your own CLIENT_ID and CLIENT_SECRET below
|
10
|
+
# 2. From terminal run "ruby last-app-user-login-to-csv.rb"
|
11
|
+
# 3. Use the command line args to filter events
|
12
|
+
#
|
13
|
+
# e.g. "ruby last-app-user-login-to-csv.rb -l 90" for last 90 days
|
14
|
+
#
|
15
|
+
|
16
|
+
|
17
|
+
# Parse CLI arguments
|
18
|
+
options = {
|
19
|
+
event_type_id: 8, # User Logged into an App
|
20
|
+
sort: '-created_at'
|
21
|
+
}
|
22
|
+
|
23
|
+
OptionParser.new do |opts|
|
24
|
+
opts.banner = "Usage: last-app-user-login-to-csv.rb [options]"
|
25
|
+
|
26
|
+
opts.on("-lLAST", "--LAST=LAST", Integer, "Events since this many days ago") do |d|
|
27
|
+
now = Date.today
|
28
|
+
days_ago = (now - d)
|
29
|
+
options[:since] = days_ago.strftime('%Y-%m-%dT%H:%M:%SZ')
|
30
|
+
end
|
31
|
+
|
32
|
+
end.parse!
|
33
|
+
|
34
|
+
client = OneLogin::Api::Client.new(
|
35
|
+
client_id: 'ONELOGIN_CLIENT_ID_GOES_HERE',
|
36
|
+
client_secret: 'ONELOGIN_CLIENT_SECRET_GOES_HERE',
|
37
|
+
region: 'us'
|
38
|
+
)
|
39
|
+
|
40
|
+
counter = 0
|
41
|
+
|
42
|
+
logins = {}
|
43
|
+
|
44
|
+
# build a hash from events which contains user_id and latest login date
|
45
|
+
client.get_events(options).each do |event|
|
46
|
+
key = "#{event.app_id}-#{event.user_id}"
|
47
|
+
|
48
|
+
unless logins[key]
|
49
|
+
logins[key] = {
|
50
|
+
app_id: event.app_id,
|
51
|
+
app_name: event.app_name,
|
52
|
+
user_id: event.user_id,
|
53
|
+
user_name: event.user_name,
|
54
|
+
last_login_at: event.created_at
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
CSV.open('last-login-by-app.csv', 'wb') do |csv|
|
60
|
+
puts "Exporting user logins to last-login-by-app.csv"
|
61
|
+
|
62
|
+
# header row
|
63
|
+
csv << ['app_id', 'app_name', 'user_id', 'user_name', 'last_login_at']
|
64
|
+
|
65
|
+
logins.each do |login|
|
66
|
+
csv << login[1].values
|
67
|
+
counter += 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
puts "Exported #{counter} user logins to last-login-by-app.csv"
|
data/lib/onelogin/api/client.rb
CHANGED
@@ -16,9 +16,10 @@ module OneLogin
|
|
16
16
|
#
|
17
17
|
class Client
|
18
18
|
include OneLogin::Api::Util
|
19
|
+
include HTTParty
|
19
20
|
|
20
21
|
attr_accessor :client_id, :client_secret, :region
|
21
|
-
attr_accessor :user_agent, :error, :error_description
|
22
|
+
attr_accessor :user_agent, :error, :error_description, :error_attribute
|
22
23
|
|
23
24
|
NOKOGIRI_OPTIONS = Nokogiri::XML::ParseOptions::STRICT |
|
24
25
|
Nokogiri::XML::ParseOptions::NONET
|
@@ -37,6 +38,10 @@ module OneLogin
|
|
37
38
|
@region = options[:region] || 'us'
|
38
39
|
@max_results = options[:max_results] || 1000
|
39
40
|
|
41
|
+
if options[:proxy_host]
|
42
|
+
self.class.http_proxy options[:proxy_host], options[:proxy_port], options[:proxy_user], options[:proxy_pass]
|
43
|
+
end
|
44
|
+
|
40
45
|
validate_config
|
41
46
|
|
42
47
|
@user_agent = DEFAULT_USER_AGENT
|
@@ -51,6 +56,7 @@ module OneLogin
|
|
51
56
|
def clean_error
|
52
57
|
@error = nil
|
53
58
|
@error_description = nil
|
59
|
+
@error_attribute = nil
|
54
60
|
end
|
55
61
|
|
56
62
|
def extract_error_message_from_response(response)
|
@@ -59,7 +65,13 @@ module OneLogin
|
|
59
65
|
if content && content.has_key?('status')
|
60
66
|
status = content['status']
|
61
67
|
if status.has_key?('message')
|
62
|
-
|
68
|
+
if status['message'].instance_of?(Hash)
|
69
|
+
if status['message'].has_key?('description')
|
70
|
+
message = status['message']['description']
|
71
|
+
end
|
72
|
+
else
|
73
|
+
message = status['message']
|
74
|
+
end
|
63
75
|
elsif status.has_key?('type')
|
64
76
|
message = status['type']
|
65
77
|
end
|
@@ -67,6 +79,20 @@ module OneLogin
|
|
67
79
|
message
|
68
80
|
end
|
69
81
|
|
82
|
+
def extract_error_attribute_from_response(response)
|
83
|
+
attribute = nil
|
84
|
+
content = JSON.parse(response.body)
|
85
|
+
if content && content.has_key?('status')
|
86
|
+
status = content['status']
|
87
|
+
if status.has_key?('message') && status['message'].instance_of?(Hash)
|
88
|
+
if status['message'].has_key?('attribute')
|
89
|
+
attribute = status['message']['attribute']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
attribute
|
94
|
+
end
|
95
|
+
|
70
96
|
def expired?
|
71
97
|
Time.now.utc > @expiration
|
72
98
|
end
|
@@ -168,7 +194,7 @@ module OneLogin
|
|
168
194
|
'grant_type' => 'client_credentials'
|
169
195
|
}
|
170
196
|
|
171
|
-
response =
|
197
|
+
response = self.class.post(
|
172
198
|
url,
|
173
199
|
headers: authorized_headers(false),
|
174
200
|
body: data.to_json
|
@@ -210,7 +236,7 @@ module OneLogin
|
|
210
236
|
'refresh_token' => @refresh_token
|
211
237
|
}
|
212
238
|
|
213
|
-
response =
|
239
|
+
response = self.class.post(
|
214
240
|
url,
|
215
241
|
headers: headers,
|
216
242
|
body: data.to_json
|
@@ -250,7 +276,7 @@ module OneLogin
|
|
250
276
|
access_token: @access_token
|
251
277
|
}
|
252
278
|
|
253
|
-
response =
|
279
|
+
response = self.class.post(
|
254
280
|
url,
|
255
281
|
headers: authorized_headers(false),
|
256
282
|
body: data.to_json
|
@@ -285,7 +311,7 @@ module OneLogin
|
|
285
311
|
begin
|
286
312
|
url = url_for(GET_RATE_URL)
|
287
313
|
|
288
|
-
response =
|
314
|
+
response = self.class.get(
|
289
315
|
url,
|
290
316
|
headers: authorized_headers
|
291
317
|
)
|
@@ -327,7 +353,8 @@ module OneLogin
|
|
327
353
|
model: OneLogin::Api::Models::User,
|
328
354
|
headers: authorized_headers,
|
329
355
|
max_results: @max_results,
|
330
|
-
params: params
|
356
|
+
params: params,
|
357
|
+
client: self.class
|
331
358
|
}
|
332
359
|
|
333
360
|
return Cursor.new(url_for(GET_USERS_URL), options)
|
@@ -355,7 +382,7 @@ module OneLogin
|
|
355
382
|
|
356
383
|
url = url_for(GET_USER_URL, user_id)
|
357
384
|
|
358
|
-
response =
|
385
|
+
response = self.class.get(
|
359
386
|
url,
|
360
387
|
headers: authorized_headers
|
361
388
|
)
|
@@ -419,7 +446,7 @@ module OneLogin
|
|
419
446
|
begin
|
420
447
|
url = url_for(GET_ROLES_FOR_USER_URL, user_id)
|
421
448
|
|
422
|
-
response =
|
449
|
+
response = self.class.get(
|
423
450
|
url,
|
424
451
|
headers: authorized_headers
|
425
452
|
)
|
@@ -454,7 +481,7 @@ module OneLogin
|
|
454
481
|
begin
|
455
482
|
url = url_for(GET_CUSTOM_ATTRIBUTES_URL)
|
456
483
|
|
457
|
-
response =
|
484
|
+
response = self.class.get(
|
458
485
|
url,
|
459
486
|
headers: authorized_headers
|
460
487
|
)
|
@@ -498,7 +525,7 @@ module OneLogin
|
|
498
525
|
begin
|
499
526
|
url = url_for(CREATE_USER_URL)
|
500
527
|
|
501
|
-
response =
|
528
|
+
response = self.class.post(
|
502
529
|
url,
|
503
530
|
headers: authorized_headers,
|
504
531
|
body: user_params.to_json
|
@@ -512,6 +539,7 @@ module OneLogin
|
|
512
539
|
else
|
513
540
|
@error = response.code.to_s
|
514
541
|
@error_description = extract_error_message_from_response(response)
|
542
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
515
543
|
end
|
516
544
|
rescue Exception => e
|
517
545
|
@error = '500'
|
@@ -541,7 +569,7 @@ module OneLogin
|
|
541
569
|
begin
|
542
570
|
url = url_for(UPDATE_USER_URL, user_id)
|
543
571
|
|
544
|
-
response =
|
572
|
+
response = self.class.put(
|
545
573
|
url,
|
546
574
|
headers: authorized_headers,
|
547
575
|
body: user_params.to_json
|
@@ -555,6 +583,7 @@ module OneLogin
|
|
555
583
|
else
|
556
584
|
@error = response.code.to_s
|
557
585
|
@error_description = extract_error_message_from_response(response)
|
586
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
558
587
|
end
|
559
588
|
rescue Exception => e
|
560
589
|
@error = '500'
|
@@ -583,7 +612,7 @@ module OneLogin
|
|
583
612
|
'role_id_array' => role_ids
|
584
613
|
}
|
585
614
|
|
586
|
-
response =
|
615
|
+
response = self.class.put(
|
587
616
|
url,
|
588
617
|
headers: authorized_headers,
|
589
618
|
body: data.to_json
|
@@ -594,6 +623,7 @@ module OneLogin
|
|
594
623
|
else
|
595
624
|
@error = response.code.to_s
|
596
625
|
@error_description = extract_error_message_from_response(response)
|
626
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
597
627
|
end
|
598
628
|
rescue Exception => e
|
599
629
|
@error = '500'
|
@@ -622,7 +652,7 @@ module OneLogin
|
|
622
652
|
'role_id_array' => role_ids
|
623
653
|
}
|
624
654
|
|
625
|
-
response =
|
655
|
+
response = self.class.put(
|
626
656
|
url,
|
627
657
|
headers: authorized_headers,
|
628
658
|
body: data.to_json
|
@@ -633,6 +663,7 @@ module OneLogin
|
|
633
663
|
else
|
634
664
|
@error = response.code.to_s
|
635
665
|
@error_description = extract_error_message_from_response(response)
|
666
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
636
667
|
end
|
637
668
|
rescue Exception => e
|
638
669
|
@error = '500'
|
@@ -665,7 +696,7 @@ module OneLogin
|
|
665
696
|
'validate_policy' => validate_policy
|
666
697
|
}
|
667
698
|
|
668
|
-
response =
|
699
|
+
response = self.class.put(
|
669
700
|
url,
|
670
701
|
headers: authorized_headers,
|
671
702
|
body: data.to_json
|
@@ -676,6 +707,7 @@ module OneLogin
|
|
676
707
|
else
|
677
708
|
@error = response.code.to_s
|
678
709
|
@error_description = extract_error_message_from_response(response)
|
710
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
679
711
|
end
|
680
712
|
rescue Exception => e
|
681
713
|
@error = '500'
|
@@ -713,7 +745,7 @@ module OneLogin
|
|
713
745
|
data['password_salt'] = password_salt
|
714
746
|
end
|
715
747
|
|
716
|
-
response =
|
748
|
+
response = self.class.put(
|
717
749
|
url,
|
718
750
|
headers: authorized_headers,
|
719
751
|
body: data.to_json
|
@@ -724,6 +756,7 @@ module OneLogin
|
|
724
756
|
else
|
725
757
|
@error = response.code.to_s
|
726
758
|
@error_description = extract_error_message_from_response(response)
|
759
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
727
760
|
end
|
728
761
|
rescue Exception => e
|
729
762
|
@error = '500'
|
@@ -752,7 +785,7 @@ module OneLogin
|
|
752
785
|
'state' => state
|
753
786
|
}
|
754
787
|
|
755
|
-
response =
|
788
|
+
response = self.class.put(
|
756
789
|
url,
|
757
790
|
headers: authorized_headers,
|
758
791
|
body: data.to_json
|
@@ -763,6 +796,7 @@ module OneLogin
|
|
763
796
|
else
|
764
797
|
@error = response.code.to_s
|
765
798
|
@error_description = extract_error_message_from_response(response)
|
799
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
766
800
|
end
|
767
801
|
rescue Exception => e
|
768
802
|
@error = '500'
|
@@ -791,7 +825,7 @@ module OneLogin
|
|
791
825
|
'custom_attributes' => custom_attributes
|
792
826
|
}
|
793
827
|
|
794
|
-
response =
|
828
|
+
response = self.class.put(
|
795
829
|
url,
|
796
830
|
headers: authorized_headers,
|
797
831
|
body: data.to_json
|
@@ -802,6 +836,7 @@ module OneLogin
|
|
802
836
|
else
|
803
837
|
@error = response.code.to_s
|
804
838
|
@error_description = extract_error_message_from_response(response)
|
839
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
805
840
|
end
|
806
841
|
rescue Exception => e
|
807
842
|
@error = '500'
|
@@ -825,7 +860,7 @@ module OneLogin
|
|
825
860
|
begin
|
826
861
|
url = url_for(LOG_USER_OUT_URL, user_id)
|
827
862
|
|
828
|
-
response =
|
863
|
+
response = self.class.put(
|
829
864
|
url,
|
830
865
|
headers: authorized_headers
|
831
866
|
)
|
@@ -835,6 +870,7 @@ module OneLogin
|
|
835
870
|
else
|
836
871
|
@error = response.code.to_s
|
837
872
|
@error_description = extract_error_message_from_response(response)
|
873
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
838
874
|
end
|
839
875
|
rescue Exception => e
|
840
876
|
@error = '500'
|
@@ -865,7 +901,7 @@ module OneLogin
|
|
865
901
|
'locked_until' => minutes
|
866
902
|
}
|
867
903
|
|
868
|
-
response =
|
904
|
+
response = self.class.put(
|
869
905
|
url,
|
870
906
|
headers: authorized_headers,
|
871
907
|
body: data.to_json
|
@@ -876,6 +912,7 @@ module OneLogin
|
|
876
912
|
else
|
877
913
|
@error = response.code.to_s
|
878
914
|
@error_description = extract_error_message_from_response(response)
|
915
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
879
916
|
end
|
880
917
|
rescue Exception => e
|
881
918
|
@error = '500'
|
@@ -899,7 +936,7 @@ module OneLogin
|
|
899
936
|
begin
|
900
937
|
url = url_for(DELETE_USER_URL, user_id)
|
901
938
|
|
902
|
-
response =
|
939
|
+
response = self.class.delete(
|
903
940
|
url,
|
904
941
|
headers: authorized_headers
|
905
942
|
)
|
@@ -909,6 +946,7 @@ module OneLogin
|
|
909
946
|
else
|
910
947
|
@error = response.code.to_s
|
911
948
|
@error_description = extract_error_message_from_response(response)
|
949
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
912
950
|
end
|
913
951
|
rescue Exception => e
|
914
952
|
@error = '500'
|
@@ -941,7 +979,7 @@ module OneLogin
|
|
941
979
|
raise "username_or_email, password and subdomain are required parameters"
|
942
980
|
end
|
943
981
|
|
944
|
-
response =
|
982
|
+
response = self.class.post(
|
945
983
|
url,
|
946
984
|
headers: authorized_headers.merge({ 'Custom-Allowed-Origin-Header-1' => allowed_origin }),
|
947
985
|
body: query_params.to_json
|
@@ -986,7 +1024,7 @@ module OneLogin
|
|
986
1024
|
data['otp_token'] = otp_token
|
987
1025
|
end
|
988
1026
|
|
989
|
-
response =
|
1027
|
+
response = self.class.post(
|
990
1028
|
url,
|
991
1029
|
headers: authorized_headers.merge({ 'Custom-Allowed-Origin-Header-1' => allowed_origin }),
|
992
1030
|
body: data.to_json
|
@@ -1054,7 +1092,7 @@ module OneLogin
|
|
1054
1092
|
begin
|
1055
1093
|
url = url_for(GET_ROLE_URL, role_id)
|
1056
1094
|
|
1057
|
-
response =
|
1095
|
+
response = self.class.get(
|
1058
1096
|
url,
|
1059
1097
|
headers: authorized_headers
|
1060
1098
|
)
|
@@ -1149,7 +1187,7 @@ module OneLogin
|
|
1149
1187
|
begin
|
1150
1188
|
url = url_for(GET_EVENT_URL, event_id)
|
1151
1189
|
|
1152
|
-
response =
|
1190
|
+
response = self.class.get(
|
1153
1191
|
url,
|
1154
1192
|
headers: authorized_headers
|
1155
1193
|
)
|
@@ -1191,7 +1229,7 @@ module OneLogin
|
|
1191
1229
|
begin
|
1192
1230
|
url = url_for(CREATE_EVENT_URL)
|
1193
1231
|
|
1194
|
-
response =
|
1232
|
+
response = self.class.post(
|
1195
1233
|
url,
|
1196
1234
|
headers: authorized_headers,
|
1197
1235
|
body: event_params.to_json
|
@@ -1202,6 +1240,7 @@ module OneLogin
|
|
1202
1240
|
else
|
1203
1241
|
@error = response.code.to_s
|
1204
1242
|
@error_description = extract_error_message_from_response(response)
|
1243
|
+
@error_attribute = extract_error_attribute_from_response(response)
|
1205
1244
|
end
|
1206
1245
|
rescue Exception => e
|
1207
1246
|
@error = '500'
|
@@ -1256,7 +1295,7 @@ module OneLogin
|
|
1256
1295
|
begin
|
1257
1296
|
url = url_for(GET_GROUP_URL, group_id)
|
1258
1297
|
|
1259
|
-
response =
|
1298
|
+
response = self.class.get(
|
1260
1299
|
url,
|
1261
1300
|
headers: authorized_headers
|
1262
1301
|
)
|
@@ -1311,7 +1350,7 @@ module OneLogin
|
|
1311
1350
|
data['ip_address'] = ip_address
|
1312
1351
|
end
|
1313
1352
|
|
1314
|
-
response =
|
1353
|
+
response = self.class.post(
|
1315
1354
|
url,
|
1316
1355
|
headers: authorized_headers,
|
1317
1356
|
body: data.to_json
|
@@ -1364,7 +1403,7 @@ module OneLogin
|
|
1364
1403
|
data['otp_token'] = otp_token
|
1365
1404
|
end
|
1366
1405
|
|
1367
|
-
response =
|
1406
|
+
response = self.class.post(
|
1368
1407
|
url,
|
1369
1408
|
headers: authorized_headers,
|
1370
1409
|
body: data.to_json
|
@@ -1402,7 +1441,7 @@ module OneLogin
|
|
1402
1441
|
begin
|
1403
1442
|
url = url_for(GET_FACTORS_URL, user_id)
|
1404
1443
|
|
1405
|
-
response =
|
1444
|
+
response = self.class.get(
|
1406
1445
|
url,
|
1407
1446
|
:headers => authorized_headers
|
1408
1447
|
)
|
@@ -1451,7 +1490,7 @@ module OneLogin
|
|
1451
1490
|
'number'=> number
|
1452
1491
|
}
|
1453
1492
|
|
1454
|
-
response =
|
1493
|
+
response = self.class.post(
|
1455
1494
|
url,
|
1456
1495
|
:headers => authorized_headers,
|
1457
1496
|
body: data.to_json
|
@@ -1488,7 +1527,7 @@ module OneLogin
|
|
1488
1527
|
begin
|
1489
1528
|
url = url_for(GET_ENROLLED_FACTORS_URL, user_id)
|
1490
1529
|
|
1491
|
-
response =
|
1530
|
+
response = self.class.get(
|
1492
1531
|
url,
|
1493
1532
|
:headers => authorized_headers
|
1494
1533
|
)
|
@@ -1530,7 +1569,7 @@ module OneLogin
|
|
1530
1569
|
begin
|
1531
1570
|
url = url_for(ACTIVATE_FACTOR_URL, user_id, device_id)
|
1532
1571
|
|
1533
|
-
response =
|
1572
|
+
response = self.class.post(
|
1534
1573
|
url,
|
1535
1574
|
headers: authorized_headers
|
1536
1575
|
)
|
@@ -1587,7 +1626,7 @@ module OneLogin
|
|
1587
1626
|
data['state_token'] = state_token
|
1588
1627
|
end
|
1589
1628
|
|
1590
|
-
response =
|
1629
|
+
response = self.class.post(
|
1591
1630
|
url,
|
1592
1631
|
headers: authorized_headers,
|
1593
1632
|
body: data.to_json
|
@@ -1622,7 +1661,7 @@ module OneLogin
|
|
1622
1661
|
begin
|
1623
1662
|
url = url_for(REMOVE_FACTOR_URL, user_id, device_id)
|
1624
1663
|
|
1625
|
-
response =
|
1664
|
+
response = self.class.delete(
|
1626
1665
|
url,
|
1627
1666
|
:headers => authorized_headers
|
1628
1667
|
)
|
@@ -1664,7 +1703,7 @@ module OneLogin
|
|
1664
1703
|
'email'=> email
|
1665
1704
|
}
|
1666
1705
|
|
1667
|
-
response =
|
1706
|
+
response = self.class.post(
|
1668
1707
|
url,
|
1669
1708
|
headers: authorized_headers,
|
1670
1709
|
body: data.to_json
|
@@ -1712,7 +1751,7 @@ module OneLogin
|
|
1712
1751
|
data['personal_email'] = personal_email
|
1713
1752
|
end
|
1714
1753
|
|
1715
|
-
response =
|
1754
|
+
response = self.class.post(
|
1716
1755
|
url,
|
1717
1756
|
headers: authorized_headers,
|
1718
1757
|
body: data.to_json
|
@@ -1744,7 +1783,7 @@ module OneLogin
|
|
1744
1783
|
clean_error
|
1745
1784
|
|
1746
1785
|
begin
|
1747
|
-
response =
|
1786
|
+
response = self.class.get(
|
1748
1787
|
EMBED_APP_URL,
|
1749
1788
|
headers: {
|
1750
1789
|
'User-Agent' => @user_agent
|
data/lib/onelogin/api/cursor.rb
CHANGED
@@ -19,6 +19,7 @@ class Cursor
|
|
19
19
|
@headers = options[:headers] || {}
|
20
20
|
@params = options[:params] || {}
|
21
21
|
@max_results = options[:max_results]
|
22
|
+
@client = options[:client]
|
22
23
|
|
23
24
|
@collection = []
|
24
25
|
@after_cursor = options.fetch(:after_cursor, nil)
|
@@ -49,7 +50,7 @@ class Cursor
|
|
49
50
|
def fetch_next_page
|
50
51
|
@params = @params.merge(after_cursor: @after_cursor) if @after_cursor
|
51
52
|
|
52
|
-
response =
|
53
|
+
response = @client.get(
|
53
54
|
@url,
|
54
55
|
headers: @headers,
|
55
56
|
query: @params
|
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.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OneLogin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- examples/all-users-to-csv.rb
|
106
106
|
- examples/create-user.rb
|
107
107
|
- examples/events-to-csv.rb
|
108
|
+
- examples/last-app-user-login-to-csv.rb
|
108
109
|
- examples/list-users.rb
|
109
110
|
- examples/rails-custom-login-page/.gitignore
|
110
111
|
- examples/rails-custom-login-page/.ruby-version
|