onelogin 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c91052998d05d2e77aa306969a4df08d6e33c07b
4
- data.tar.gz: 47b18c4ac2681e82d16cf4b591545e410f185634
3
+ metadata.gz: 58c499d12ba910854c224b2e7280e0705ece7eef
4
+ data.tar.gz: a76418a9f64073ee882bcc0c0488d396d83f831e
5
5
  SHA512:
6
- metadata.gz: 70c17995bcc43243a87e6fdaa3061c992de2bc6209d980707fa5f624a611a43a962c5fe9810e0f395b884b6cab1bc42664596c9e726cdc28bb4e663b842ff582
7
- data.tar.gz: 11b280b60df068f7e6585839c1e6ea3c7f60f679297d7f44d70a22f0ac172b0260c5a4ec69775239f2f3eea030e006cbf17332d1c8a86466bf8628daf2c66bc1
6
+ metadata.gz: 33852679c25f500dc0957abc8038fe22d9df7410bbf87a48c33e48c4ead2458f4424714089a87feda5f789715e4989cbebbb762ca9dd7e8c8940bbe683c2eb7f
7
+ data.tar.gz: 3962ba7ca01cff4b33c80865d6eae2fb7b58dff1749bb97b51cf59dcbc4b253944b831654e0f38b63d53a4ef1690db0098c40721b1b182cd2e6a76e1ff7efa7a
data/.gitignore CHANGED
@@ -7,3 +7,6 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ .DS_Store
12
+ .rspec_status
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.11.2
4
+ - 1.9.3
5
+ - 2.4.1
6
+ before_install: gem install bundler -v 1.15.3
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,24 +1,41 @@
1
- # Contributor Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
7
4
 
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
12
22
 
13
23
  Examples of unacceptable behavior by participants include:
14
24
 
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
18
28
  * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
22
39
 
23
40
  Project maintainers have the right and responsibility to remove, edit, or
24
41
  reject comments, commits, code, wiki edits, issues, and other contributions
@@ -26,24 +43,32 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
26
43
  permanently any contributor for other behaviors that they deem inappropriate,
27
44
  threatening, offensive, or harmful.
28
45
 
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
33
54
 
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
55
+ ## Enforcement
36
56
 
37
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at chandra@cloudfactory.com. All
58
+ reported by contacting the project team at richardchetwynd@gmail.com. All
39
59
  complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
43
69
 
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
47
72
 
48
73
  [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.com'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in onelogin.gemspec
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in onelogin-ruby-sdk.gemspec
4
6
  gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010-2017 OneLogin, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
- # Onelogin
1
+ # OneLogin Ruby SDK
2
+
3
+ This SDK will let you execute all the API methods, version/1, described
4
+ at https://developers.onelogin.com/api-docs/1/getting-started/dev-overview.
5
+
6
+ The toolkit is hosted on github. You can download it from:
7
+ * Lastest release: https://github.com/onelogin/onelogin-ruby-sdk/releases/latest
8
+ * Master repo: https://github.com/onelogin/onelogin-ruby-sdk/tree/master
2
9
 
3
- This Gem use OneLogin’s product API to interact with your organization’s data and to develop third-party apps that incorporate and build upon OneLogin’s core product features.
4
- For more info visit [OneLogin Api Doc](https://developers.onelogin.com/docs)
5
10
 
6
11
  ## Installation
7
12
 
@@ -19,9 +24,296 @@ Or install it yourself as:
19
24
 
20
25
  $ gem install onelogin
21
26
 
27
+
28
+ ### Dependencies
29
+
30
+ * httparty
31
+
32
+ ## Getting started
33
+
34
+ You'll need a OneLogin account and a set of API credentials before you get started.
35
+
36
+ If you don't have an account you can [sign up for a free developer account here](https://www.onelogin.com/developer-signup).
37
+
38
+ |||
39
+ |---|---|
40
+ |client_id|Required: A valid OneLogin API client_id|
41
+ |client_secret|Required: A valid OneLogin API client_secret|
42
+ |region| Optional: `us` or `eu`. Defaults to `us` |
43
+ |max_results| Optional: Defaults to 1000 |
44
+
45
+ ```ruby
46
+ require 'onelogin'
47
+
48
+ client = OneLogin::Api::Client.new(
49
+ client_id: '',
50
+ client_secret:'',
51
+ region: 'us'
52
+ )
53
+
54
+ # Now you can make requests
55
+ client.get_users
56
+ ```
57
+
58
+ For all methods see Rubydoc of this SDK published at:
59
+ http://www.rubydoc.info/github/onelogin/onelogin-ruby-sdk
60
+
61
+
22
62
  ## Usage
23
63
 
24
- TODO: Write usage instructions here
64
+ ### Errors and exceptions
65
+
66
+ OneLogin's API can return 400, 401, 403 or 404 when there was any issue executing the action. When that happens, the methods of the SDK will include error and errorMessage in the client. Use `error` and `error_description` of the Client to retrieve them.
67
+
68
+ ```ruby
69
+ users = client.get_users
70
+
71
+ if users.nil?
72
+ puts client.error
73
+ puts client.error_description
74
+ end
75
+ ```
76
+
77
+ ### Authentication
78
+
79
+ 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.
80
+
81
+ ```ruby
82
+ # Get an AccessToken
83
+ token = client.get_access_token
84
+
85
+ # Refresh an AccessToken
86
+ token2 = client.regenerate_token
87
+
88
+ # Revoke an AccessToken
89
+ token3 = client.get_access_token
90
+ ```
91
+
92
+ ### Paging
93
+ All OneLogin API endpoints that support paging are returned as enumerations to save you keeping track of the paging cursor.
94
+
95
+ User `take` to limit the results or get all results by enumerating.
96
+
97
+ e.g.
98
+ ```ruby
99
+ # List the first name of all users
100
+ client.get_users.each do |user|
101
+ puts user.firstname
102
+ end
103
+
104
+ # List the first name of all users starting with the 2nd user
105
+ # `each` accepts a start param to skip first x results
106
+ client.get_users.each(1) do |user|
107
+ puts user.firstname
108
+ end
109
+
110
+ # List the first 5 users with the name of Joe
111
+ client.get_users(firstname: 'Joe').take(5).each do |user|
112
+ puts "#{user.firstname} #{user.lastname}"
113
+ end
114
+
115
+ # Get 10 event ids
116
+ client.get_events.take(10).map{|event| event.id }
117
+
118
+ # Get all roles
119
+ client.get_roles.to_a
120
+ ```
121
+
122
+ For safety where some collections (e.g. `get_events`) have large numbers of resources there is a
123
+ limit of 1000 total results returned. You can override this with the `max_results` param during Client initialization.
124
+
125
+ ```
126
+ client = OneLogin::Api::Client.new(
127
+ client_id: '',
128
+ client_secret:'',
129
+ max_results: 50000
130
+ )
131
+
132
+ client.get_events.map {|event| event.id}
133
+ ```
134
+
135
+
136
+
137
+ ### Available Methods
138
+
139
+ ```ruby
140
+ # Get rate limits
141
+ rate_limits = client.get_rate_limits
142
+
143
+ # Get Custom Attributes
144
+ custom_global_attributes = client.get_custom_attributes
145
+
146
+ # Get Users with no query parameters
147
+ users = client.get_users
148
+
149
+ # Get Users with query parameters
150
+ query_parameters = {
151
+ email: "user@example.com"
152
+ }
153
+ users_filtered = client.get_users(query_parameters)
154
+
155
+ query_parameters = {
156
+ email: "usermfa@example.com"
157
+ }
158
+ users_filtered2 = client.get_users(query_parameters)
159
+
160
+ # Get Users with limit
161
+ query_parameters = {
162
+ limit: 3
163
+ }
164
+ users_filtered_limited = client.get_users(query_parameters)
165
+
166
+ # Only return the firstname and email fields for each user
167
+ client.get_users(fields: 'email,firstname').each do |user|
168
+ puts "#{user.firstname} - #{user.email}"
169
+ end
170
+
171
+ # Get User by id
172
+ user = client.get_user(users_filtered.first.id)
173
+ user_mfa = client.get_user(users_filtered2.first.id)
174
+
175
+ # Update User with specific id
176
+ user = client.get_user(user.id)
177
+ update_user_params = user.get_user_params
178
+ update_user_params["firstname"] = 'modified_firstname'
179
+ user = client.update_user(user.id, update_user_params)
180
+ user = client.get_user(user.id)
181
+
182
+ # Get Global Roles
183
+ roles = client.get_roles
184
+
185
+ # Get Role
186
+ role = client.get_role(1234)
187
+
188
+ # Assign & Remove Roles On Users
189
+ role_ids = [
190
+ 1234, 5678
191
+ ]
192
+ result = client.assign_role_to_user(user.id, role_ids)
193
+ role_ids.pop
194
+ result = client.remove_role_from_user(user.id, role_ids)
195
+ user = client.get_user(user.id)
196
+
197
+ # Sets Password by ID Using Cleartext
198
+ password = "Aa765431-XxX"
199
+ result = client.set_password_using_clear_text(user.id, password, password)
200
+
201
+ # Sets Password by ID Using Salt and SHA-256
202
+ password = "Aa765432-YyY"
203
+ salt = "11xxxx1"
204
+
205
+ require 'digest'
206
+ sha256 = Digest::SHA256.new
207
+ hashed_salted_password = sha256.hexdigest("#{pw}#{salt}")
208
+ result = client.set_password_using_hash_salt(user_mfa.id, hashed_salted_password, hashed_salted_password, "salt+sha256", salt)
209
+
210
+ Set Custom Attribute Value to User
211
+ customAttributes = {
212
+ custom_global_attributes[0]=> "xxxx",
213
+ custom_global_attributes[1]=> "yyyy"
214
+ }
215
+ result = client.set_custom_attribute_to_user(34687020, customAttributes)
216
+
217
+ # Log Out User
218
+ result = client.log_user_out(user.id)
219
+
220
+ # Lock User
221
+ result = client.lock_user(user.id, 5)
222
+
223
+ # Get User apps
224
+ apps = client.get_user_apps(user.id)
225
+
226
+ # Get User Roles
227
+ role_ids = client.get_user_roles(user.id)
228
+
229
+ # Create user
230
+ new_user_params = {
231
+ email: "testcreate_1@example.com",
232
+ firstname: "testcreate_1_fn",
233
+ lastname: "testcreate_1_ln",
234
+ username: "testcreate_1@example.com"
235
+ }
236
+ created_user = client.create_user(new_user_params)
237
+
238
+ # Delete User
239
+ result = client.delete_user(created_user.id)
240
+
241
+ # Create Session Login Token
242
+ session_login_token_params = {
243
+ username_or_email: "user@example.com",
244
+ password: "Aa765431-XxX",
245
+ subdomain: "example-onelogin-subdomain"
246
+ }
247
+ session_token_data = client.create_session_login_token(session_login_token_params)
248
+
249
+ # Create Session Login Token MFA , after verify
250
+ session_login_token_mfa_params = {
251
+ username_or_email: "usermfa@example.com",
252
+ password: "Aa765432-YyY",
253
+ subdomain: "example-onelogin-subdomain"
254
+ }
255
+ session_token_mfa_data = client.create_session_login_token(session_login_token_mfa_params)
256
+ otp_token = "000000" # We get this value from OTP device
257
+ session_token_data2 = client.get_session_token_verified(session_token_mfa_data.devices[0].id,session_token_mfa_data.state_token, otp_token)
258
+
259
+ # Get EventTypes
260
+ event_types = client.get_event_types
261
+
262
+ # Get Events
263
+ events = client.get_events
264
+
265
+ query_events_params = {
266
+ limit: 2
267
+ }
268
+ events_limited = client.get_events(query_events_params)
269
+
270
+ # Get Event
271
+ event = client.get_event(events[0].id)
272
+
273
+ # Create Event
274
+ new_event_params = {
275
+ event_type_id: "000",
276
+ account_id: "00000",
277
+ actor_system: "00",
278
+ user_id: "00000000",
279
+ user_name: "test_event",
280
+ custom_message: "test creating event from python :)"
281
+ }
282
+ result = client.create_event(new_event_params)
283
+
284
+ # Get Filtered Events
285
+ query_events_params = array(
286
+ user_id: "00000000"
287
+ )
288
+ events = client.get_events(query_events_params)
289
+
290
+ # Get Groups
291
+ groups = client.get_groups
292
+
293
+ # Get Group
294
+ group = client.get_group(groups.first.id)
295
+
296
+ # Get SAMLResponse directly
297
+ app_id = "000000"
298
+ saml_endpoint_response = client.get_saml_assertion("user@example.com", "Aa765431-XxX", app_id, "example-onelogin-subdomain")
299
+
300
+ # Get SAMLResponse after MFA
301
+ saml_endpoint_response2 = client.get_saml_assertion("usermfa@example.com", "Aa765432-YyY", app_id, "example-onelogin-subdomain")
302
+ mfa = saml_endpoint_response2.mfa
303
+ otp_token = "000000"
304
+ saml_endpoint_response_after_verify = client.get_saml_assertion_verifying(app_id, mfa.devices[0].id, mfa.state_token, "78395727", nil)
305
+
306
+ # Generate Invite Link
307
+ url_link = client.generate_invite_link("user@example.com")
308
+
309
+ # Send Invite Link
310
+ sent = client.send_invite_link("user@example.com")
311
+
312
+ #Get Apps to Embed for a User
313
+ embed_token = "30e256c101cd0d2e731de1ec222e93c4be8a1572"
314
+ apps = client.get_embed_apps("30e256c101cd0d2e731de1ec222e93c4be8a1572", "user@example.com")
315
+ ```
316
+
25
317
 
26
318
  ## Development
27
319
 
@@ -31,10 +323,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
31
323
 
32
324
  ## Contributing
33
325
 
34
- Bug reports and pull requests are welcome on GitHub at https://github.com/cmthakur/onelogin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
35
-
326
+ Bug reports and pull requests are welcome on GitHub at https://github.com/onelogin/onelogin-ruby-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
327
 
37
328
  ## License
38
329
 
39
330
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
331
 
332
+ ## Code of Conduct
333
+
334
+ Everyone interacting in the OneLogin Ruby Sdk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/onelogin/onelogin-ruby-sdk/blob/master/CODE_OF_CONDUCT.md).
data/bin/console CHANGED
@@ -11,4 +11,4 @@ require "onelogin"
11
11
  # Pry.start
12
12
 
13
13
  require "irb"
14
- IRB.start
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here