descope 1.0.6 → 1.1.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +51 -12
  3. data/.github/workflows/publish-gem.yaml +6 -26
  4. data/.github/workflows/release-please.yaml +36 -0
  5. data/.gitignore +5 -2
  6. data/.release-please-manifest.json +1 -1
  7. data/.ruby-version +1 -1
  8. data/CHANGELOG.md +21 -0
  9. data/Gemfile +8 -7
  10. data/Gemfile.lock +70 -56
  11. data/README.md +170 -51
  12. data/examples/ruby-on-rails-api/descope/Gemfile +8 -8
  13. data/examples/ruby-on-rails-api/descope/Gemfile.lock +1 -1
  14. data/examples/ruby-on-rails-api/descope/package-lock.json +203 -141
  15. data/examples/ruby-on-rails-api/descope/package.json +1 -1
  16. data/examples/ruby-on-rails-api/descope/yarn.lock +185 -87
  17. data/lib/descope/api/v1/auth/enchantedlink.rb +3 -1
  18. data/lib/descope/api/v1/auth/magiclink.rb +3 -1
  19. data/lib/descope/api/v1/auth/otp.rb +3 -1
  20. data/lib/descope/api/v1/auth/password.rb +6 -2
  21. data/lib/descope/api/v1/auth/totp.rb +3 -1
  22. data/lib/descope/api/v1/auth.rb +47 -12
  23. data/lib/descope/api/v1/management/common.rb +20 -5
  24. data/lib/descope/api/v1/management/sso_application.rb +236 -0
  25. data/lib/descope/api/v1/management/sso_settings.rb +2 -24
  26. data/lib/descope/api/v1/management/user.rb +151 -13
  27. data/lib/descope/api/v1/management.rb +2 -0
  28. data/lib/descope/api/v1/session.rb +37 -4
  29. data/lib/descope/mixins/common.rb +1 -0
  30. data/lib/descope/mixins/http.rb +60 -9
  31. data/lib/descope/mixins/initializer.rb +5 -2
  32. data/lib/descope/mixins/logging.rb +12 -4
  33. data/lib/descope/version.rb +1 -1
  34. data/spec/descope/api/v1/auth_spec.rb +29 -0
  35. data/spec/descope/api/v1/auth_token_extraction_spec.rb +126 -0
  36. data/spec/descope/api/v1/session_refresh_spec.rb +98 -0
  37. data/spec/factories/user.rb +1 -1
  38. data/spec/integration/lib.descope/api/v1/auth/enchantedlink_spec.rb +20 -22
  39. data/spec/integration/lib.descope/api/v1/auth/magiclink_spec.rb +6 -2
  40. data/spec/integration/lib.descope/api/v1/auth/otp_spec.rb +6 -2
  41. data/spec/integration/lib.descope/api/v1/auth/session_spec.rb +68 -0
  42. data/spec/integration/lib.descope/api/v1/auth/totp_spec.rb +6 -2
  43. data/spec/integration/lib.descope/api/v1/management/access_key_spec.rb +12 -1
  44. data/spec/integration/lib.descope/api/v1/management/audit_spec.rb +5 -3
  45. data/spec/integration/lib.descope/api/v1/management/authz_spec.rb +28 -5
  46. data/spec/integration/lib.descope/api/v1/management/flow_spec.rb +3 -1
  47. data/spec/integration/lib.descope/api/v1/management/permissions_spec.rb +22 -2
  48. data/spec/integration/lib.descope/api/v1/management/project_spec.rb +18 -2
  49. data/spec/integration/lib.descope/api/v1/management/roles_spec.rb +116 -36
  50. data/spec/integration/lib.descope/api/v1/management/user_spec.rb +74 -8
  51. data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +11 -2
  52. data/spec/lib.descope/api/v1/auth/password_spec.rb +10 -1
  53. data/spec/lib.descope/api/v1/auth_spec.rb +167 -5
  54. data/spec/lib.descope/api/v1/cookie_domain_fix_integration_spec.rb +245 -0
  55. data/spec/lib.descope/api/v1/management/sso_application_spec.rb +217 -0
  56. data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +2 -2
  57. data/spec/lib.descope/api/v1/management/user_spec.rb +134 -46
  58. data/spec/lib.descope/api/v1/session_spec.rb +119 -6
  59. data/spec/lib.descope/mixins/http_spec.rb +229 -0
  60. data/spec/support/client_config.rb +0 -1
  61. data/spec/support/utils.rb +21 -0
  62. metadata +14 -8
data/README.md CHANGED
@@ -5,7 +5,7 @@ for a backend written in Ruby. You can read more on the [Descope Website](https:
5
5
 
6
6
  ## Requirements
7
7
 
8
- The SDK supports Ruby 3.2 and above.
8
+ The SDK supports Ruby 3.3.0 and above.
9
9
 
10
10
  ## Installing the SDK
11
11
 
@@ -37,6 +37,17 @@ Be aware that only the management key is truncated, and the JWT responses are pr
37
37
 
38
38
  Do not run with log level debug on Production!
39
39
 
40
+ ### Logging
41
+
42
+ You can customize logging behavior:
43
+
44
+ ```ruby
45
+ # Use your application's logger
46
+ descope_client = Descope::Client.new(
47
+ project_id: '<project_id>',
48
+ logger: Rails.logger # or any Logger-compatible object
49
+ )
50
+ ```
40
51
 
41
52
  ## Authentication Methods
42
53
  These sections show how to use the SDK to perform various authentication/authorization functions:
@@ -45,13 +56,14 @@ These sections show how to use the SDK to perform various authentication/authori
45
56
  2. [Magic Link](#magic-link)
46
57
  3. [Enchanted Link](#enchanted-link)
47
58
  4. [OAuth](#oauth)
48
- 5. [SSO/SAML](#ssosaml)
59
+ 5. [SSO (SAML / OIDC)](#sso-saml-oidc)
49
60
  6. [TOTP Authentication](#totp-authentication)
50
61
  7. [Passwords](#passwords)
51
62
  8. [Session Validation](#session-validation)
52
63
  9. [Roles & Permission Validation](#roles-permission-validation)
53
64
  10. [Tenant selection](#tenant-selection)
54
- 11. [Logging Out](#logging-out)
65
+ 11. [Signing Out](#signing-out)
66
+ 12. [History](#history)
55
67
 
56
68
  ## API Management Function
57
69
 
@@ -66,10 +78,12 @@ These sections show how to use the SDK to perform permission and user management
66
78
  7. [Query SSO Groups](#query-sso-groups)
67
79
  8. [Manage Flows](#manage-flows-and-theme)
68
80
  9. [Manage JWTs](#manage-jwts)
69
- 10. [Embedded links](#embedded-links)
70
- 11. [Audit](#audit)
71
- 12. [Manage ReBAC Authz](#manage-rebac-authz)
72
- 13. [Manage Project](#manage-project)
81
+ 10. [Impersonate](#impersonate)
82
+ 11. [Embedded links](#embedded-links)
83
+ 12. [Audit](#audit)
84
+ 13. [Manage ReBAC Authz](#manage-rebac-authz)
85
+ 14. [Manage Project](#manage-project)
86
+ 15. [Manage SSO Applications](#manage-sso-applications)
73
87
 
74
88
  If you wish to run any of our code examples and play with them, check out our [Code Examples](#code-examples) section.
75
89
 
@@ -79,7 +93,7 @@ For rate limiting information, please confer to the [API Rate Limits](#api-rate-
79
93
 
80
94
  ### OTP Authentication
81
95
 
82
- Send a user a one-time password (OTP) using your preferred delivery method (email/SMS/Voice call). An email address or phone number must be provided accordingly.
96
+ Send a user a one-time password (OTP) using your preferred delivery method (Email/SMS/Voice call). An email address or phone number must be provided accordingly.
83
97
 
84
98
  The user can either `sign up`, `sign in` or `sign up or in`
85
99
 
@@ -88,32 +102,32 @@ The user can either `sign up`, `sign in` or `sign up or in`
88
102
  # For sign up either phone or email is required
89
103
  email = 'desmond@descope.com'
90
104
  user = {'name': 'Desmond Copeland', 'phone': '212-555-1234', 'email': email}
91
- masked_address = descope_client.otp_sign_up(method: DeliveryMethod.EMAIL, login_id: 'someone@example.com', user: user)
105
+ masked_address = descope_client.otp_sign_up(method: Descope::Mixins::Common::DeliveryMethod::EMAIL, login_id: 'someone@example.com', user: user)
92
106
  ```
93
107
 
94
108
  The user will receive a code using the selected delivery method. Verify that code using:
95
109
 
96
110
  ```ruby
97
111
  jwt_response = descope_client.otp_verify_code(
98
- method: DeliveryMethod.EMAIL, login_id: 'someone@example.com', code: '123456'
112
+ method: Descope::Mixins::Common::DeliveryMethod::EMAIL, login_id: 'someone@example.com', code: '123456'
99
113
  )
100
- session_token = jwt_response['sessionJwt']
101
- refresh_token = jwt_response['refreshJwt']
114
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
115
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
102
116
  ```
103
117
 
104
118
  The session and refresh JWTs should be returned to the caller, and passed with every request in the session. Read more on [session validation](#session-validation)
105
119
 
106
120
  ### Magic Link
107
121
 
108
- Send a user a Magic Link using your preferred delivery method (_email / SMS_).
109
- The Magic Link will redirect the user to page where the its token needs to be verified.
122
+ Send a user a Magic Link using your preferred delivery method (Email / SMS).
123
+ The Magic Link will redirect the user to page where the token needs to be verified.
110
124
  This redirection can be configured in code, or generally in the [Descope Console](https://app.descope.com/settings/authentication/magiclink)
111
125
 
112
126
  The user can either `sign up`, `sign in` or `sign up or in`
113
127
 
114
128
  ```ruby
115
129
  masked_address = descope_client.magiclink_sign_up_or_in(
116
- method: DeliveryMethod.EMAIL,
130
+ method: Descope::Mixins::Common::DeliveryMethod::EMAIL,
117
131
  login_id: 'desmond@descope.com',
118
132
  uri: 'https://myapp.com/verify-magic-link', # Set redirect URI here or via console
119
133
  )
@@ -123,8 +137,8 @@ To verify a magic link, your redirect page must call the validation function on
123
137
 
124
138
  ```ruby
125
139
  jwt_response = descope_client.magiclink_verify_token('token-here')
126
- session_token = jwt_response['sessionJwt']
127
- refresh_token = jwt_response['refreshJwt']
140
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
141
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
128
142
  ```
129
143
 
130
144
  The session and refresh JWTs should be returned to the caller, and passed with every request in the session. Read more on [session validation](#session-validation)
@@ -143,7 +157,7 @@ This method is similar to [Magic Link](#magic-link) but differs in two major way
143
157
  - This supports cross-device clicking, meaning the user can try to log in on one device,
144
158
  like a computer, while clicking the link on another device, for instance a mobile phone.
145
159
 
146
- The Enchanted Link will redirect the user to page where the its token needs to be verified.
160
+ The Enchanted Link will redirect the user to a page where the token needs to be verified.
147
161
  This redirection can be configured in code per request, or set globally in the [Descope Console](https://app.descope.com/settings/authentication/enchantedlink).
148
162
 
149
163
  The user can either `sign up`, `sign in` or `sign up or in`
@@ -162,6 +176,9 @@ After sending the link, you must poll to receive a valid session using the `pend
162
176
  the previous step. A valid session will be returned only after the user clicks the right link.
163
177
 
164
178
  ```ruby
179
+
180
+ pending_ref = res['pendingRef']
181
+
165
182
  def poll_for_session(descope_client, pending_ref)
166
183
  max_tries = 15
167
184
  i = 0
@@ -175,15 +192,15 @@ def poll_for_session(descope_client, pending_ref)
175
192
  jwt_response = descope_client.enchanted_link_get_session(pending_ref)
176
193
  done = true
177
194
  rescue Descope::AuthException, Descope::Unauthorized => e
178
- puts 'Failed pending session, err: #{e}'
195
+ puts "Failed pending session, err: #{e}"
179
196
  nil
180
197
  end
181
198
 
182
199
  if jwt_response
183
- puts 'jwt_response: #{jwt_response}'
200
+ puts "jwt_response: #{jwt_response}"
184
201
  refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME]['jwt']
185
202
 
186
- puts 'refresh_token: #{refresh_token}'
203
+ puts "refresh_token: #{refresh_token}"
187
204
  puts :'Done logging out!'
188
205
  descope_client.sign_out(refresh_token)
189
206
  puts 'User logged out'
@@ -202,7 +219,8 @@ begin
202
219
  descope_client.enchanted_link_verify_token(token=token)
203
220
  # Token is valid
204
221
  rescue AuthException => e
205
- # Token is invalid
222
+ # Token is invalid
223
+ puts "Failed to verify token, err: #{e}"
206
224
  end
207
225
  ```
208
226
 
@@ -224,13 +242,13 @@ The user will authenticate with the authentication provider, and will be redirec
224
242
 
225
243
  ```ruby
226
244
  jwt_response = descope_client.oauth_exchange_token(code)
227
- session_token = jwt_response['sessionJwt']
228
- refresh_token = jwt_response['refreshJwt']
245
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
246
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
229
247
  ```
230
248
 
231
249
  The session and refresh JWTs should be returned to the caller, and passed with every request in the session. Read more on [session validation](#session-validation)
232
250
 
233
- ### SSO/SAML
251
+ ### SSO (SAML / OIDC)
234
252
 
235
253
  Users can authenticate to a specific tenant using SAML or Single Sign On. Configure your SSO/SAML settings on the [Descope console](https://app.descope.com/settings/authentication/sso). To start a flow call:
236
254
 
@@ -247,8 +265,8 @@ The user will authenticate with the authentication provider configured for that
247
265
 
248
266
  ```ruby
249
267
  jwt_response = descope_client.saml_exchange_token(code)
250
- session_token = jwt_response['sessionJwt']
251
- refresh_token = jwt_response['refreshJwt']
268
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
269
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
252
270
  ```
253
271
 
254
272
  The session and refresh JWTs should be returned to the caller, and passed with every request in the session. Read more on [session validation](#session-validation)
@@ -256,7 +274,7 @@ The session and refresh JWTs should be returned to the caller, and passed with e
256
274
  ### TOTP Authentication
257
275
 
258
276
  The user can authenticate using an authenticator app, such as Google Authenticator.
259
- Sign up like you would using any other authentication method. The sign up response
277
+ Sign up like you would use any other authentication method. The sign-up response
260
278
  will then contain a QR code `image` that can be displayed to the user to scan using
261
279
  their mobile device camera app, or the user can enter the `key` manually or click
262
280
  on the link provided by the `provisioning_url`.
@@ -267,7 +285,7 @@ Existing users can add TOTP using the `update` function.
267
285
  # Every user must have a login ID. All other user information is optional
268
286
  email = 'desmond@descope.com'
269
287
  user = {name: 'Desmond Copeland', phone: '212-555-1234', email: 'someone@example.com'}
270
- totp_response = descope_client.totp_sign_up(method: DeliveryMethod.EMAIL, login_id: 'someone@example.com', user: user)
288
+ totp_response = descope_client.totp_sign_up(method: Descope::Mixins::Common::DeliveryMethod::EMAIL, login_id: 'someone@example.com', user: user)
271
289
 
272
290
  # Use one of the provided options to have the user add their credentials to the authenticator
273
291
  provisioning_url = totp_response['provisioningURL']
@@ -285,8 +303,8 @@ jwt_response = descope_client.totp_sign_in_code(
285
303
  login_id: 'someone@example.com',
286
304
  code: '123456' # Code from authenticator app
287
305
  )
288
- session_token = jwt_response['sessionJwt']
289
- refresh_token = jwt_response['refreshJwt']
306
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
307
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
290
308
  ```
291
309
 
292
310
  The session and refresh JWTs should be returned to the caller, and passed with every request in the session. Read more on [session validation](#session-validation)
@@ -307,16 +325,16 @@ user = {
307
325
  email: login_id,
308
326
  }
309
327
  jwt_response = descope_client.password_sign_up(login_id:, password:, user:)
310
- session_token = jwt_response['sessionJwt']
311
- refresh_token = jwt_response['refreshJwt']
328
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
329
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
312
330
  ```
313
331
 
314
332
  The user can later sign in using the same login_id and password.
315
333
 
316
334
  ```ruby
317
335
  jwt_response = descope_client.password_sign_in(login_id:, password:)
318
- session_token = jwt_response['sessionJwt']
319
- refresh_token = jwt_response['refreshJwt']
336
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
337
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
320
338
  ```
321
339
 
322
340
  The session and refresh JWTs should be returned to the caller, and passed with every request in the session. Read more on [session validation](#session-validation)
@@ -325,7 +343,7 @@ In case the user needs to update their password, one of two methods are availabl
325
343
 
326
344
  **Changing Passwords**
327
345
 
328
- _NOTE: send_reset will only work if the user has a validated email address. Otherwise password reset prompts cannot be sent._
346
+ _NOTE: send_reset will only work if the user has a validated email address. Otherwise, password reset prompts cannot be sent._
329
347
 
330
348
  In the [password authentication method](https://app.descope.com/settings/authentication/password) in the Descope console, it is possible to define which alternative authentication method can be used in order to authenticate the user, in order to reset and update their password.
331
349
 
@@ -353,8 +371,8 @@ Alternatively, it is also possible to replace an existing active password with a
353
371
  ```ruby
354
372
  # Replaces the user's current password with a new one
355
373
  jwt_response = descope_client.password_replace(login_id: 'login', old_password: '1234', new_password: '4567')
356
- session_token = jwt_response['sessionJwt']
357
- refresh_token = jwt_response['refreshJwt']
374
+ session_token = jwt_response[Descope::Mixins::Common::SESSION_TOKEN_NAME].fetch('jwt')
375
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
358
376
  ```
359
377
 
360
378
  ### Session Validation
@@ -380,19 +398,19 @@ jwt_response = descope_client.validate_and_refresh_session('session_token', 'ref
380
398
 
381
399
  Choose the right session validation and refresh combination that suits your needs.
382
400
 
383
- Note: all those validation apis can receive an optional 'audience' parameter that should be provided when using jwt that has the 'aud' claim)
401
+ Note: all those validation apis can receive an optional 'audience' parameter that should be provided when using jwt that has the 'aud' claim.
384
402
 
385
403
  Refreshed sessions return the same response as is returned when users first sign up / log in,
386
- containing the session and refresh tokens, as well as all of the JWT claims.
404
+ containing the session and refresh tokens, as well as all the JWT claims.
387
405
  Make sure to return the tokens from the response to the client, or updated the cookie if you're using it.
388
406
 
389
407
  Usually, the tokens can be passed in and out via HTTP headers or via a cookie.
390
408
  The implementation can defer according to your framework of choice. See our [examples](#code-examples) for a few examples.
391
409
 
392
- If Roles & Permissions are used, validate them immediately after validating the session. See the [next section](#roles--permission-validation)
410
+ If Roles & Permissions are used, validate them immediately after validating the session. See the [next section](#roles-permission-validation)
393
411
  for more information.
394
412
 
395
- ### Roles & Permission Validation
413
+ ### Roles Permission Validation
396
414
 
397
415
  When using Roles & Permission, it's important to validate the user has the required
398
416
  authorization immediately after making sure the session is valid. Taking the `jwt_response`
@@ -459,13 +477,23 @@ After calling this function, you must invalidate or remove any cookies you have
459
477
  descope_client.sign_out('refresh_token')
460
478
  ```
461
479
 
462
- It is also possible to sign the user out of all the devices they are currently signed-in with. Calling `logout_all` will
480
+ It is also possible to sign the user out of all the devices they are currently signed in with. Calling `logout_all` will
463
481
  invalidate all user's refresh tokens. After calling this function, you must invalidate or remove any cookies you have created.
464
482
 
465
483
  ```ruby
466
484
  descope_client.sign_out_all('refresh_token')
467
485
  ```
468
486
 
487
+ ### History
488
+ You can get the current session user history.
489
+ The request requires a valid refresh token.
490
+
491
+ ```ruby
492
+ users_history_resp = descope_client.history(refresh_token)
493
+ for user_history in users_history_resp:
494
+ # Do something
495
+ ```
496
+
469
497
  ## Management API
470
498
 
471
499
  It is very common for some form of management or automation to be required. These can be performed
@@ -570,6 +598,16 @@ descope_client.update_user(
570
598
  user_tenants: client.associated_tenants_to_hash_array(associated_tenants)
571
599
  )
572
600
 
601
+ # Patch all user attribute in one api call
602
+ descope_client.patch_user(
603
+ login_id: 'desmond@descope.com',
604
+ email: 'desmond@descope.com',
605
+ given_name: 'Desmond',
606
+ family_name: 'Copeland',
607
+ display_name: 'Desmond Copeland',
608
+ user_tenants: client.associated_tenants_to_hash_array(associated_tenants)
609
+ )
610
+
573
611
  # Update explicit data for a user rather than overriding all fields
574
612
  descope_client.update_login_id(
575
613
  login_id: 'desmond@descope.com',
@@ -760,7 +798,7 @@ descope_client.update_role(
760
798
  descope_client.delete_role(name: 'My Updated Role', tenant_id: 'The tenant ID to which this role is associated, leave empty, if role is a global one')
761
799
 
762
800
  # Load all roles
763
- roles_resp = descope_client.load_all_roles()
801
+ roles_resp = descope_client.load_all_roles
764
802
  roles = roles_resp['roles']
765
803
  roles.each do |role|
766
804
  # Do something
@@ -769,11 +807,13 @@ roles = roles_resp['roles']
769
807
  ```
770
808
 
771
809
  # Search roles
810
+
811
+ ```ruby
772
812
  roles_resp = descope_client.search_roles(
773
- names: ['role1', 'role2'], # Search for roles with the names 'role1' and 'role2'
774
- role_name_like: 'role', # Search for roles that contain the string 'role'
775
- tenant_ids: ['tenant1', 'tenant2'], # Search for roles that are associated with the tenants 'tenant1' and 'tenant2'
776
- permission_names: ['permission1', 'permission2'] # Search for roles that have the permissions 'permission1' and 'permission2'
813
+ names: %w[role1 role2], # Search for roles with the names 'role1' and 'role2'
814
+ role_name_like: 'role', # Search for roles that contain the string 'role'
815
+ tenant_ids: %w[tenant1 tenant2], # Search for roles that are associated with the tenants 'tenant1' and 'tenant2'
816
+ permission_names: %w[permission1 permission2] # Search for roles that have the permissions 'permission1' and 'permission2'
777
817
  )
778
818
 
779
819
  roles = roles_resp['roles']
@@ -1124,6 +1164,13 @@ descope_client.create_test_user(
1124
1164
  user_tenants: client.associated_tenants_to_hash_array(associated_tenants)
1125
1165
  )
1126
1166
 
1167
+ # Search all test users, optionally according to tenant and/or role filter
1168
+ # results can be paginated using the limit and page parameters
1169
+ users_resp = descope_client.search_all_test_users()
1170
+ users = users_resp["users"]
1171
+ users.each do |user|
1172
+ # Do something
1173
+
1127
1174
  # Now test user got created, and this user will be available until you delete it,
1128
1175
  # you can use any management operation for test user CRUD.
1129
1176
  # You can also delete all test users.
@@ -1131,14 +1178,14 @@ descope_client.delete_all_test_users
1131
1178
 
1132
1179
  # OTP code can be generated for test user, for example:
1133
1180
  resp = descope_client.generate_otp_for_test_user(
1134
- method: DeliveryMethod.EMAIL, login_id: 'login-id'
1181
+ method: Descope::Mixins::Common::DeliveryMethod::EMAIL, login_id: 'login-id'
1135
1182
  )
1136
1183
  code = resp['code']
1137
1184
  # Now you can verify the code is valid (using descope_client.*.verify for example)
1138
1185
 
1139
1186
  # Same as OTP, magic link can be generated for test user, for example:
1140
1187
  resp = descope_client.generate_magic_link_for_test_user(
1141
- method: DeliveryMethod.EMAIL,
1188
+ method: Descope::Mixins::Common::DeliveryMethod::EMAIL,
1142
1189
  login_id: 'login-id',
1143
1190
  )
1144
1191
  link = resp['link']
@@ -1151,6 +1198,78 @@ link = resp['link']
1151
1198
  pending_ref = resp['pendingRef']
1152
1199
  ```
1153
1200
 
1201
+ ### Manage SSO Applications
1202
+
1203
+ You can create, update, delete or load SSO applications:
1204
+
1205
+ ```ruby
1206
+ descope_client.create_sso_oidc_app(
1207
+ name: "My First sso app",
1208
+ login_page_url: "https://dummy.com/login",
1209
+ id: "my-custom-id", # this is optional
1210
+ )
1211
+
1212
+ # Create SAML sso application
1213
+ descope_client.create_saml_application(
1214
+ name: "My First sso app",
1215
+ login_page_url: "https://dummy.com/login",
1216
+ id: "my-custom-id", # this is optional
1217
+ use_metadata_info: true,
1218
+ metadata_url: "https://dummy.com/metadata",
1219
+ default_relay_state: "relayState",
1220
+ force_authentication: false,
1221
+ logout_redirect_url: "https://dummy.com/logout",
1222
+ )
1223
+ ```
1224
+
1225
+ # Update OIDC sso application
1226
+ # Update will override all fields as is. Use carefully.
1227
+
1228
+ ```ruby
1229
+ descope_client.update_sso_oidc_app(
1230
+ id: "my-custom-id",
1231
+ name: "My First sso app",
1232
+ login_page_url: "https://dummy.com/login",
1233
+ )
1234
+ ````
1235
+
1236
+ # Update SAML sso application
1237
+ # Update will override all fields as is. Use carefully.
1238
+
1239
+ ```ruby
1240
+ descope_client.update_saml_application(
1241
+ id: "my-custom-id",
1242
+ name: "My First sso app",
1243
+ login_page_url: "https://dummy.com/login",
1244
+ use_metadata_info: false,
1245
+ entity_id: "ent1234",
1246
+ acs_url: "https://dummy.com/acs",
1247
+ certificate: "my cert"
1248
+ )
1249
+ ```
1250
+
1251
+ # SSO application deletion cannot be undone. Use carefully.
1252
+
1253
+ ```ruby
1254
+ descope_client.delete_sso_app('my-custom-id')
1255
+ ```
1256
+
1257
+ # Load SSO application by id
1258
+
1259
+ ```ruby
1260
+ descope_client.load_sso_app('my-custom-id')
1261
+ ```
1262
+
1263
+ # Load all SSO applications
1264
+
1265
+ ```ruby
1266
+ resp = descope_client.load_all_sso_apps
1267
+ resp["apps"].each do |app|
1268
+ # Do something
1269
+ end
1270
+ ```
1271
+
1272
+
1154
1273
  ## API Rate Limits
1155
1274
 
1156
1275
  Handle API rate limits by comparing the exception to the APIRateLimitExceeded exception, which includes the RateLimitParameters map with the key 'Retry-After.' This key indicates how many seconds until the next valid API call can take place.
@@ -1158,7 +1277,7 @@ Handle API rate limits by comparing the exception to the APIRateLimitExceeded ex
1158
1277
  ```ruby
1159
1278
  begin
1160
1279
  descope_client.magiclink_sign_up_or_in(
1161
- method: DeliveryMethod.EMAIL,
1280
+ method: Descope::Mixins::Common::DeliveryMethod::EMAIL,
1162
1281
  login_id: 'desmond@descope.com',
1163
1282
  uri: 'https://myapp.com/verify-magic-link',
1164
1283
  )
@@ -3,12 +3,12 @@ source "https://rubygems.org"
3
3
  ruby "3.3.0"
4
4
 
5
5
  # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6
- gem "rails", "~> 7.1.3.2"
6
+ gem "rails", "~> 7.1.3.3"
7
7
 
8
8
  gem 'descope', path: '../../../..'
9
9
 
10
10
  # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
11
- gem "sprockets-rails"
11
+ gem "sprockets-rails", ">= 3.5.0"
12
12
 
13
13
  # Use sqlite3 as the database for Active Record
14
14
  gem "sqlite3", "~> 1.4"
@@ -17,19 +17,19 @@ gem "sqlite3", "~> 1.4"
17
17
  gem "puma", ">= 5.0"
18
18
 
19
19
  # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
20
- gem "jsbundling-rails"
20
+ gem "jsbundling-rails", ">= 1.3.1"
21
21
 
22
22
  # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
23
- gem "turbo-rails"
23
+ gem "turbo-rails", ">= 2.0.6"
24
24
 
25
25
  # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
26
- gem "stimulus-rails"
26
+ gem "stimulus-rails", ">= 1.3.4"
27
27
 
28
28
  # Bundle and process CSS [https://github.com/rails/cssbundling-rails]
29
- gem "cssbundling-rails"
29
+ gem "cssbundling-rails", ">= 1.4.1"
30
30
 
31
31
  # Build JSON APIs with ease [https://github.com/rails/jbuilder]
32
- gem "jbuilder"
32
+ gem "jbuilder", ">= 2.12.0"
33
33
 
34
34
  # Use Redis adapter to run Action Cable in production
35
35
  # gem "redis", ">= 4.0.1"
@@ -63,7 +63,7 @@ group :development do
63
63
 
64
64
  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
65
65
  # gem "spring"
66
- gem 'rubocop-rails', '2.24.1', require: false
66
+ gem 'rubocop-rails', '2.25.0', require: false
67
67
  gem "rdoc", ">= 6.6.3.1", require: false
68
68
  end
69
69
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../../..
3
3
  specs:
4
- descope (1.0.5)
4
+ descope (1.0.6)
5
5
  addressable (~> 2.8)
6
6
  jwt (~> 2.7)
7
7
  rest-client (~> 2.1)