descope 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +15 -27
  3. data/.github/workflows/publish-gem.yaml +36 -0
  4. data/Gemfile +12 -14
  5. data/Gemfile.lock +40 -87
  6. data/README.md +39 -17
  7. data/examples/ruby/access_key_app.rb +4 -2
  8. data/examples/ruby/management/Gemfile.lock +2 -2
  9. data/examples/ruby/management/role_app.rb +8 -3
  10. data/examples/ruby-on-rails-api/descope/.gitignore +58 -28
  11. data/examples/ruby-on-rails-api/descope/Gemfile.lock +3 -3
  12. data/examples/ruby-on-rails-api/descope/app/assets/builds/App.css +62 -0
  13. data/examples/ruby-on-rails-api/descope/app/assets/builds/App.css.map +7 -0
  14. data/examples/ruby-on-rails-api/descope/app/assets/builds/application.css +62 -0
  15. data/examples/ruby-on-rails-api/descope/app/assets/builds/application.css.map +7 -0
  16. data/examples/ruby-on-rails-api/descope/app/assets/builds/application.js +40369 -0
  17. data/examples/ruby-on-rails-api/descope/app/assets/builds/application.js.map +7 -0
  18. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/App.css +62 -0
  19. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/App.css.map +7 -0
  20. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/App.js +27979 -0
  21. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/App.js.map +7 -0
  22. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Dashboard.css +62 -0
  23. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Dashboard.css.map +7 -0
  24. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Dashboard.js +27118 -0
  25. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Dashboard.js.map +7 -0
  26. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Home.css +62 -0
  27. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Home.css.map +7 -0
  28. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Home.js +27113 -0
  29. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Home.js.map +7 -0
  30. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Login.css +62 -0
  31. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Login.css.map +7 -0
  32. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Login.js +27131 -0
  33. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Login.js.map +7 -0
  34. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Profile.css +62 -0
  35. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Profile.css.map +7 -0
  36. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Profile.js +27168 -0
  37. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/Profile.js.map +7 -0
  38. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/index.css +62 -0
  39. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/index.css.map +7 -0
  40. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/index.js +28250 -0
  41. data/examples/ruby-on-rails-api/descope/app/assets/builds/components/index.js.map +7 -0
  42. data/examples/ruby-on-rails-api/descope/app/assets/builds/controllers/application.js +2456 -0
  43. data/examples/ruby-on-rails-api/descope/app/assets/builds/controllers/application.js.map +7 -0
  44. data/examples/ruby-on-rails-api/descope/app/assets/builds/controllers/index.js +2453 -0
  45. data/examples/ruby-on-rails-api/descope/app/assets/builds/controllers/index.js.map +7 -0
  46. data/examples/ruby-on-rails-api/descope/app/assets/builds/reportWebVitals.js +211 -0
  47. data/examples/ruby-on-rails-api/descope/app/assets/builds/reportWebVitals.js.map +7 -0
  48. data/examples/ruby-on-rails-api/descope/app/assets/builds/routes/index.css +62 -0
  49. data/examples/ruby-on-rails-api/descope/app/assets/builds/routes/index.css.map +7 -0
  50. data/examples/ruby-on-rails-api/descope/app/assets/builds/routes/index.js +27973 -0
  51. data/examples/ruby-on-rails-api/descope/app/assets/builds/routes/index.js.map +7 -0
  52. data/examples/ruby-on-rails-api/descope/package-lock.json +7 -8
  53. data/examples/ruby-on-rails-api/descope/yarn.lock +3 -3
  54. data/lib/descope/api/v1/auth.rb +21 -6
  55. data/lib/descope/api/v1/management/access_key.rb +5 -4
  56. data/lib/descope/api/v1/management/common.rb +4 -1
  57. data/lib/descope/api/v1/management/role.rb +22 -6
  58. data/lib/descope/api/v1/management/user.rb +17 -0
  59. data/lib/descope/mixins/common.rb +2 -12
  60. data/lib/descope/mixins/http.rb +1 -1
  61. data/lib/descope/version.rb +1 -1
  62. data/spec/integration/lib.descope/api/v1/auth/enchantedlink_spec.rb +81 -0
  63. data/spec/integration/lib.descope/api/v1/auth/magiclink_spec.rb +49 -0
  64. data/spec/integration/lib.descope/api/v1/auth/otp_spec.rb +38 -0
  65. data/spec/integration/lib.descope/api/v1/auth/password_spec.rb +41 -0
  66. data/spec/integration/lib.descope/api/v1/auth/totp_spec.rb +76 -0
  67. data/spec/integration/lib.descope/api/v1/management/access_key_spec.rb +62 -0
  68. data/spec/integration/lib.descope/api/v1/management/audit_spec.rb +16 -0
  69. data/spec/integration/lib.descope/api/v1/management/authz_spec.rb +187 -0
  70. data/spec/integration/lib.descope/api/v1/management/flow_spec.rb +44 -0
  71. data/spec/integration/lib.descope/api/v1/management/permissions_spec.rb +27 -0
  72. data/spec/integration/lib.descope/api/v1/management/project_spec.rb +29 -0
  73. data/spec/integration/lib.descope/api/v1/management/roles_spec.rb +116 -0
  74. data/spec/integration/lib.descope/api/v1/management/user_spec.rb +262 -0
  75. data/spec/lib.descope/api/v1/auth_spec.rb +50 -1
  76. data/spec/lib.descope/api/v1/management/access_key_spec.rb +4 -2
  77. data/spec/lib.descope/api/v1/management/role_spec.rb +35 -6
  78. data/spec/lib.descope/api/v1/management/user_spec.rb +40 -0
  79. data/spec/spec_helper.rb +9 -38
  80. data/spec/support/client_config.rb +5 -1
  81. data/spec/support/dummy_class.rb +15 -1
  82. data/spec/support/utils.rb +1 -1
  83. metadata +56 -4
  84. data/examples/ruby-on-rails-api/descope/tmp/pids/.keep +0 -0
  85. data/examples/ruby-on-rails-api/descope/tmp/storage/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cbfd697e21207d7a3d5da5c544ad159369e7e51456461532f41608e13022d3d
4
- data.tar.gz: 7bbf26b7613fb3699933760f428c17e97ed51089fb46567f28fa74334e3f89f1
3
+ metadata.gz: cec3cb315d2015591a727a55440f878d49df010ad72f31522eb93bf927bc1cf8
4
+ data.tar.gz: e207e1b64908011868e269257d2879d2ebc112025e56cea97a15aed0eefc8dbc
5
5
  SHA512:
6
- metadata.gz: 70d3208d9fb671fa6878e0e344c0a3638ededf2cf5cd3ba0f35e81931f0279a30ebbbfedbbce0a66c7caf59bb22e8f767e08a354ca6cde8422c77ff25a1d5c2c
7
- data.tar.gz: f19dfe58eda7ff846949b7bd722cf3d7de09ce806f0bdfb6679ef4a68b2cebb86aa01a51fb80f6f69a927fb21ab9b7d1baec24d87345a68b4c0536ce484564af
6
+ metadata.gz: 46585ad1d53f2383c9458d310ae8e41a13bb3da9c72479b5ebd4e91f73544f8d4cb7dca8e3e2b4704e87f4532046a014bb4b5f3c7206d53a1a37da1634e152e9
7
+ data.tar.gz: 47383953f8613b0ae07e3ced035d5f06392faeec4b7cb0756bdc2dc7793c75c607f99b54bd46ea292cfb62ce55767e0b364ba04c39a46718e3507693262e0599
@@ -7,10 +7,18 @@ on:
7
7
  pull_request:
8
8
  branches:
9
9
  - main
10
+ workflow_dispatch:
11
+ inputs:
12
+ DESCOPE_LOG_LEVEL:
13
+ description: "Descope Log Level"
14
+ default: "info"
15
+
16
+ env:
17
+ DESCOPE_LOG_LEVEL: ${{ github.event.inputs.DESCOPE_LOG_LEVEL || 'info' }}
10
18
 
11
19
  jobs:
12
- build:
13
- name: Build Ruby SDK
20
+ ci:
21
+ name: Descope Ruby SDK CI
14
22
  runs-on: ubuntu-latest
15
23
  steps:
16
24
  - name: Checkout Code
@@ -25,30 +33,10 @@ jobs:
25
33
  run: bundle install
26
34
 
27
35
  - name: Run RSpec Test
28
- run: bundle exec rspec
29
-
30
- # in order to release use conventional commits
31
- # $ git commit --allow-empty -m "chore: release 1.0.0" -m "Release-As: 1.0.0" && git push
32
- # this will open a new PR with the changelog and bump the version
33
- # Release Please assumes you are using Conventional Commit messages.
34
- #
35
- # The most important prefixes you should have in mind are:
36
- #
37
- # fix: which represents bug fixes, and correlates to a SemVer patch.
38
- # feat: which represents a new feature, and correlates to a SemVer minor.
39
- # feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
40
- - uses: google-github-actions/release-please-action@v4
41
- id: release
42
- if: github.ref == 'refs/heads/main'
36
+ run: bundle exec rspec spec/lib.descope
43
37
 
44
- - name: Publish to RubyGems
45
- run: |
46
- mkdir -p $HOME/.gem
47
- touch $HOME/.gem/credentials
48
- chmod 0600 $HOME/.gem/credentials
49
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
50
- gem build *.gemspec
51
- gem push *.gem
38
+ - name: Run RSpec Integration Tests
52
39
  env:
53
- GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
54
- if: ${{ steps.release.outputs.release_created }}
40
+ DESCOPE_MANAGEMENT_KEY: ${{ secrets.DESCOPE_MANAGEMENT_KEY }}
41
+ DESCOPE_PROJECT_ID: ${{ secrets.DESCOPE_PROJECT_ID }}
42
+ run: bundle exec rspec spec/integration
@@ -0,0 +1,36 @@
1
+ name: Publish Ruby Gem
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+ pull-requests: read # to detect changes files
10
+
11
+ jobs:
12
+ publish-gem:
13
+ name: Publish Ruby Gem
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout Code
17
+ uses: actions/checkout@v4
18
+
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ # We are not letting this step to run bundle install, we will do it later
22
+ bundler-cache: false
23
+
24
+ - name: Install dependencies
25
+ run: bundle install
26
+
27
+ - name: Publish to RubyGems
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem build *.gemspec
34
+ gem push *.gem
35
+ env:
36
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
data/Gemfile CHANGED
@@ -1,22 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
3
5
 
4
6
  group :development do
5
- gem 'terminal-notifier-guard', require: false unless ENV['CIRCLECI']
6
- gem 'coveralls', require: false
7
- gem 'rubocop', require: false
8
- gem 'rubocop-rails', require: false
9
- gem 'irb', require: false
7
+ gem 'rubocop', '1.60.2', require: false
8
+ gem 'rubocop-rails', '2.23.1', require: false
10
9
  end
11
10
 
12
11
  group :test do
13
- gem 'webmock', require: false
14
- gem 'simplecov-cobertura'
15
- gem 'timecop', require: false
16
- gem 'rack-test', require: false
17
- gem 'dotenv', require: false
18
- gem 'super_diff', require: false
19
- gem 'factory_bot', require: 'false'
20
- gem 'selenium-webdriver', require: false
21
- gem 'rotp', require: false
12
+ gem 'factory_bot', '6.4.6', require: false
13
+ gem 'faker', require: false
14
+ gem 'rack-test', '2.1.0', require: false
15
+ gem 'rotp', '6.3.0', require: false
16
+ gem 'rspec', '3.13.0', require: false
17
+ gem 'selenium-webdriver', '4.17.0', require: false
18
+ gem 'simplecov', '0.22.0', require: false
19
+ gem 'super_diff', '0.11.0', require: false
22
20
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- descope (1.0.4)
4
+ descope (1.0.5)
5
5
  addressable (~> 2.8)
6
6
  jwt (~> 2.7)
7
7
  rest-client (~> 2.1)
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (7.1.3)
14
+ activesupport (7.1.3.2)
15
15
  base64
16
16
  bigdecimal
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -26,71 +26,50 @@ GEM
26
26
  ast (2.4.2)
27
27
  attr_extras (7.1.0)
28
28
  base64 (0.2.0)
29
- bigdecimal (3.1.6)
29
+ bigdecimal (3.1.7)
30
30
  concurrent-ruby (1.2.3)
31
31
  connection_pool (2.4.1)
32
- coveralls (0.7.1)
33
- multi_json (~> 1.3)
34
- rest-client
35
- simplecov (>= 0.7)
36
- term-ansicolor
37
- thor
38
- crack (0.4.5)
39
- rexml
40
- diff-lcs (1.5.0)
32
+ diff-lcs (1.5.1)
41
33
  docile (1.4.0)
42
34
  domain_name (0.6.20240107)
43
- dotenv (2.8.1)
44
- drb (2.2.0)
45
- ruby2_keywords
46
- factory_bot (6.4.5)
35
+ drb (2.2.1)
36
+ factory_bot (6.4.6)
47
37
  activesupport (>= 5.0.0)
48
- faker (2.23.0)
38
+ faker (3.2.3)
49
39
  i18n (>= 1.8.11, < 2)
50
40
  fuubar (2.5.1)
51
41
  rspec-core (~> 3.0)
52
42
  ruby-progressbar (~> 1.4)
53
- hashdiff (1.1.0)
54
43
  http-accept (1.7.0)
55
44
  http-cookie (1.0.5)
56
45
  domain_name (~> 0.5)
57
- i18n (1.14.1)
46
+ i18n (1.14.4)
58
47
  concurrent-ruby (~> 1.0)
59
- io-console (0.7.2)
60
- irb (1.11.1)
61
- rdoc
62
- reline (>= 0.4.2)
63
48
  json (2.7.1)
64
- jwt (2.7.1)
49
+ jwt (2.8.1)
50
+ base64
65
51
  language_server-protocol (3.17.0.3)
66
52
  mime-types (3.5.2)
67
53
  mime-types-data (~> 3.2015)
68
- mime-types-data (3.2023.1205)
69
- minitest (5.21.2)
70
- multi_json (1.15.0)
54
+ mime-types-data (3.2024.0305)
55
+ minitest (5.22.3)
71
56
  mutex_m (0.2.0)
72
57
  netrc (0.11.0)
73
58
  optimist (3.1.0)
74
59
  parallel (1.24.0)
75
- parser (3.3.0.4)
60
+ parser (3.3.0.5)
76
61
  ast (~> 2.4.1)
77
62
  racc
78
63
  patience_diff (1.2.0)
79
64
  optimist (~> 3.0)
80
- psych (5.1.2)
81
- stringio
82
65
  public_suffix (5.0.4)
83
66
  racc (1.7.3)
84
- rack (3.0.8)
67
+ rack (3.0.9.1)
85
68
  rack-test (2.1.0)
86
69
  rack (>= 1.3)
87
70
  rainbow (3.1.1)
88
71
  rake (13.1.0)
89
- rdoc (6.6.2)
90
- psych (>= 4.0.0)
91
72
  regexp_parser (2.9.0)
92
- reline (0.4.2)
93
- io-console (~> 0.5)
94
73
  rest-client (2.1.0)
95
74
  http-accept (>= 1.7.0, < 2.0)
96
75
  http-cookie (>= 1.0.2, < 2.0)
@@ -99,20 +78,20 @@ GEM
99
78
  retryable (3.0.5)
100
79
  rexml (3.2.6)
101
80
  rotp (6.3.0)
102
- rspec (3.12.0)
103
- rspec-core (~> 3.12.0)
104
- rspec-expectations (~> 3.12.0)
105
- rspec-mocks (~> 3.12.0)
106
- rspec-core (3.12.2)
107
- rspec-support (~> 3.12.0)
108
- rspec-expectations (3.12.3)
81
+ rspec (3.13.0)
82
+ rspec-core (~> 3.13.0)
83
+ rspec-expectations (~> 3.13.0)
84
+ rspec-mocks (~> 3.13.0)
85
+ rspec-core (3.13.0)
86
+ rspec-support (~> 3.13.0)
87
+ rspec-expectations (3.13.0)
109
88
  diff-lcs (>= 1.2.0, < 2.0)
110
- rspec-support (~> 3.12.0)
111
- rspec-mocks (3.12.6)
89
+ rspec-support (~> 3.13.0)
90
+ rspec-mocks (3.13.0)
112
91
  diff-lcs (>= 1.2.0, < 2.0)
113
- rspec-support (~> 3.12.0)
114
- rspec-support (3.12.1)
115
- rubocop (1.60.1)
92
+ rspec-support (~> 3.13.0)
93
+ rspec-support (3.13.1)
94
+ rubocop (1.60.2)
116
95
  json (~> 2.3)
117
96
  language_server-protocol (>= 3.17.0)
118
97
  parallel (~> 1.10)
@@ -123,15 +102,14 @@ GEM
123
102
  rubocop-ast (>= 1.30.0, < 2.0)
124
103
  ruby-progressbar (~> 1.7)
125
104
  unicode-display_width (>= 2.4.0, < 3.0)
126
- rubocop-ast (1.30.0)
127
- parser (>= 3.2.1.0)
105
+ rubocop-ast (1.31.2)
106
+ parser (>= 3.3.0.4)
128
107
  rubocop-rails (2.23.1)
129
108
  activesupport (>= 4.2.0)
130
109
  rack (>= 1.1)
131
110
  rubocop (>= 1.33.0, < 2.0)
132
111
  rubocop-ast (>= 1.30.0, < 2.0)
133
112
  ruby-progressbar (1.13.0)
134
- ruby2_keywords (0.0.5)
135
113
  rubyzip (2.3.2)
136
114
  selenium-webdriver (4.17.0)
137
115
  base64 (~> 0.2)
@@ -142,63 +120,38 @@ GEM
142
120
  docile (~> 1.1)
143
121
  simplecov-html (~> 0.11)
144
122
  simplecov_json_formatter (~> 0.1)
145
- simplecov-cobertura (2.1.0)
146
- rexml
147
- simplecov (~> 0.19)
148
123
  simplecov-html (0.12.3)
149
124
  simplecov_json_formatter (0.1.4)
150
- stringio (3.1.0)
151
- super_diff (0.10.0)
125
+ super_diff (0.11.0)
152
126
  attr_extras (>= 6.2.4)
153
127
  diff-lcs
154
128
  patience_diff
155
- sync (0.5.0)
156
- term-ansicolor (1.7.1)
157
- tins (~> 1.0)
158
- terminal-notifier-guard (1.7.0)
159
- thor (1.3.0)
160
- timecop (0.9.8)
161
- tins (1.32.1)
162
- sync
163
129
  tzinfo (2.0.6)
164
130
  concurrent-ruby (~> 1.0)
165
131
  unicode-display_width (2.5.0)
166
- webmock (3.19.1)
167
- addressable (>= 2.8.0)
168
- crack (>= 0.3.2)
169
- hashdiff (>= 0.4.0, < 2.0.0)
170
132
  websocket (1.2.10)
171
133
  zache (0.13.1)
172
134
 
173
135
  PLATFORMS
174
- arm64-darwin-22
175
136
  arm64-darwin-23
176
- x86_64-darwin-23
177
137
  x86_64-linux
178
138
 
179
139
  DEPENDENCIES
180
140
  bundler
181
141
  concurrent-ruby (~> 1.1)
182
- coveralls
183
142
  descope!
184
- dotenv
185
- factory_bot
186
- faker (~> 2.0)
143
+ factory_bot (= 6.4.6)
144
+ faker
187
145
  fuubar (~> 2.0)
188
- irb
189
- rack-test
146
+ rack-test (= 2.1.0)
190
147
  rake (~> 13.0)
191
- rotp
192
- rspec (~> 3.11)
193
- rubocop
194
- rubocop-rails
195
- selenium-webdriver
196
- simplecov (~> 0.9)
197
- simplecov-cobertura
198
- super_diff
199
- terminal-notifier-guard
200
- timecop
201
- webmock
148
+ rotp (= 6.3.0)
149
+ rspec (= 3.13.0)
150
+ rubocop (= 1.60.2)
151
+ rubocop-rails (= 2.23.1)
152
+ selenium-webdriver (= 4.17.0)
153
+ simplecov (= 0.22.0)
154
+ super_diff (= 0.11.0)
202
155
 
203
156
  BUNDLED WITH
204
- 2.4.19
157
+ 2.5.6
data/README.md CHANGED
@@ -1,8 +1,3 @@
1
- Descope SDK for Ruby
2
-
3
-
4
- The Descope SDK for Ruby provides convenient access to the Descope user management and authentication API for a backend written in Ruby. You can read more on the Descope Website.
5
-
6
1
  # Descope SDK for Ruby
7
2
 
8
3
  The Descope SDK for Ruby provides convenient access to the Descope user management and authentication API
@@ -36,6 +31,13 @@ descope_client = Descope::Client.new(
36
31
  )
37
32
  ```
38
33
 
34
+ ### Important Logging note
35
+ You may pass `log_level: 'debug'` to the client config or use `DESCOPE_LOG_LEVEL` env var.
36
+ Be aware that only the management key is truncated, and the JWT responses are printed on debug
37
+
38
+ Do not run with log level debug on Production!
39
+
40
+
39
41
  ## Authentication Methods
40
42
  These sections show how to use the SDK to perform various authentication/authorization functions:
41
43
 
@@ -77,7 +79,7 @@ For rate limiting information, please confer to the [API Rate Limits](#api-rate-
77
79
 
78
80
  ### OTP Authentication
79
81
 
80
- Send a user a one-time password (OTP) using your preferred delivery method (_email / SMS_). An email address or phone number must be provided accordingly.
82
+ Send a user a one-time password (OTP) using your preferred delivery method (email/SMS). An email address or phone number must be provided accordingly.
81
83
 
82
84
  The user can either `sign up`, `sign in` or `sign up or in`
83
85
 
@@ -385,7 +387,7 @@ containing the session and refresh tokens, as well as all of the JWT claims.
385
387
  Make sure to return the tokens from the response to the client, or updated the cookie if you're using it.
386
388
 
387
389
  Usually, the tokens can be passed in and out via HTTP headers or via a cookie.
388
- The implementation can defer according to your framework of choice. See our [samples](#code-samples) for a few examples.
390
+ The implementation can defer according to your framework of choice. See our [examples](#code-examples) for a few examples.
389
391
 
390
392
  If Roles & Permissions are used, validate them immediately after validating the session. See the [next section](#roles--permission-validation)
391
393
  for more information.
@@ -614,13 +616,15 @@ end
614
616
 
615
617
  #### Set or Expire User Password
616
618
 
617
- You can set or expire a user's password.
618
- Note: When setting a password, it will automatically be set as expired.
619
- The user will not be able log-in using an expired password, and will be required replace it on next login.
619
+ You can set a new active password for a user, which they can then use to sign in. You can also set a temporary
620
+ password that the user will be forced to change on the next login.
620
621
 
621
622
  ```ruby
623
+ # Set a user's temporary password
624
+ descope_client.set_temporary_password(login_id: '<login-id>', password: '<some-password>');
625
+
622
626
  # Set a user's password
623
- descope_client.set_password(login_id: '<login-id>', password: '<some-password>');
627
+ descope_client.set_active_password(login_id: '<login-id>', password: '<some-password>');
624
628
 
625
629
  # Or alternatively, expire a user password
626
630
  descope_client.expire_password('<login-id>')
@@ -633,12 +637,14 @@ You can create, update, delete or load access keys, as well as search according
633
637
  ```ruby
634
638
  # An access key must have a name and expiration, other fields are optional.
635
639
  # Roles should be set directly if no tenants exist, otherwise set
636
- # on a per-tenant basis.
640
+ # on a per-tenant basis. If custom_claims supplied they will be presented on the jwt.
641
+ # If customClaims is supplied, then those claims will be present in the JWT returned by calls to ExchangeAccessKey.
637
642
  associated_tenants = [{ tenant_id: 'tenant_id1', role_names: %w[role_name1 role_name2] }]
638
643
  create_resp = descope_client.create_access_key(
639
644
  name: 'name',
640
645
  expire_time: 1677844931,
641
- key_tenants: associated_tenants
646
+ key_tenants: associated_tenants,
647
+ custom_claims: {'k1': 'v1'}
642
648
  )
643
649
  key = create_resp['key']
644
650
  cleartext = create_resp['cleartext'] # make sure to save the returned cleartext securely. It will not be returned again.
@@ -738,6 +744,7 @@ descope_client.create_role(
738
744
  name: 'My Role',
739
745
  description: 'Optional description to briefly explain what this role allows.',
740
746
  permission_names: ['My Updated Permission'],
747
+ tenant_id: 'Optionally scope this role for this specific tenant. If left empty, the role will be available to all tenants.'
741
748
  )
742
749
 
743
750
  # Update will override all fields as is. Use carefully.
@@ -745,11 +752,12 @@ descope_client.update_role(
745
752
  name: 'My Role',
746
753
  new_name: 'My Updated Role',
747
754
  description: 'A revised description',
748
- permission_names: ['My Updated Permission', 'Another Permission']
755
+ permission_names: ['My Updated Permission', 'Another Permission'],
756
+ tenant_id: 'The tenant ID to which this role is associated, leave empty, if role is a global one'
749
757
  )
750
758
 
751
759
  # Role deletion cannot be undone. Use carefully.
752
- descope_client.delete_role('My Updated Role')
760
+ 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')
753
761
 
754
762
  # Load all roles
755
763
  roles_resp = descope_client.load_all_roles()
@@ -760,6 +768,20 @@ roles = roles_resp['roles']
760
768
  #
761
769
  ```
762
770
 
771
+ # Search roles
772
+ 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'
777
+ )
778
+
779
+ roles = roles_resp['roles']
780
+ roles.each do |role|
781
+ # Do something
782
+ end
783
+ ```
784
+
763
785
  ### Manage Flows and Theme
764
786
 
765
787
  You can list your flows and also import and export flows and screens, or the project theme:
@@ -1132,9 +1154,9 @@ end
1132
1154
  # This variable indicates how many seconds until the next valid API call can take place.
1133
1155
  ```
1134
1156
 
1135
- ## Code Samples
1157
+ ## Code Examples
1136
1158
 
1137
- You can find various usage samples in the [samples folder](https://github.com/descope/ruby-sdk/blob/main/samples).
1159
+ You can find various usage examples in the [examples folder](https://github.com/descope/ruby-sdk/blob/main/examples).
1138
1160
 
1139
1161
  ## Run Locally
1140
1162
 
@@ -11,7 +11,6 @@ require 'descope'
11
11
  @logger.info("Initializing Descope API with project_id: #{@project_id} and base_uri: #{@base_uri}")
12
12
 
13
13
  @client = Descope::Client.new({ project_id: @project_id, management_key: @management_key })
14
-
15
14
  access_key = nil
16
15
 
17
16
  begin
@@ -23,7 +22,10 @@ begin
23
22
  end
24
23
 
25
24
  begin
26
- jwt_response = @client.exchange_access_key(access_key)
25
+ login_options = {
26
+ customClaims: { "k1": 'v1' }
27
+ }
28
+ jwt_response = @client.exchange_access_key(access_key:, login_options:)
27
29
  @logger.info('exchange access key successfully')
28
30
  @logger.info("jwt_response: #{jwt_response}")
29
31
 
@@ -3,7 +3,7 @@ GEM
3
3
  specs:
4
4
  addressable (2.8.6)
5
5
  public_suffix (>= 2.0.2, < 6.0)
6
- descope (1.0.0)
6
+ descope (1.0.4)
7
7
  addressable (~> 2.8)
8
8
  jwt (~> 2.7)
9
9
  rest-client (~> 2.1)
@@ -16,7 +16,7 @@ GEM
16
16
  jwt (2.7.1)
17
17
  mime-types (3.5.2)
18
18
  mime-types-data (~> 3.2015)
19
- mime-types-data (3.2023.1205)
19
+ mime-types-data (3.2024.0206)
20
20
  netrc (0.11.0)
21
21
  public_suffix (5.0.4)
22
22
  rest-client (2.1.0)
@@ -15,9 +15,13 @@ require 'descope'
15
15
  name = 'My Role'
16
16
 
17
17
  begin
18
+ @logger.info('Creating a new tenant')
19
+ puts 'Please insert a new tenant name'
20
+ tenant_name = gets.chomp
21
+ tenant = @client.create_tenant(name: tenant_name)
18
22
  @logger.info('Going to create a new role')
19
23
  @client.create_role(
20
- name:, description: 'Allowed to test :)', permission_names: ['SSO Admin']
24
+ name:, description: 'Allowed to test :)', permission_names: ['SSO Admin'], tenant_id: tenant['id']
21
25
  )
22
26
  rescue Descope::AuthException => e
23
27
  @logger.info("Role creation failed #{e}")
@@ -41,7 +45,8 @@ begin
41
45
  name:,
42
46
  new_name: 'My Updated Role',
43
47
  description: 'New Description',
44
- permission_names: ['User Admin']
48
+ permission_names: ['User Admin'],
49
+ tenant_id: tenant['id']
45
50
  )
46
51
 
47
52
  rescue Descope::AuthException => e
@@ -50,7 +55,7 @@ end
50
55
 
51
56
  begin
52
57
  @logger.info('Deleting newly created role')
53
- @client.delete_role('My Updated Role')
58
+ @client.delete_role(name: 'My Updated Role', tenant_id: tenant['id'])
54
59
 
55
60
  rescue Descope::AuthException => e
56
61
  @logger.error("Role deletion failed #{e}")
@@ -1,15 +1,15 @@
1
- # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile '~/.gitignore_global'
6
-
7
- # Ignore bundler config.
8
- /.bundle
9
-
10
- # Ignore all environment files (except templates).
11
- /.env*
12
- !/.env*.erb
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /db/*.sqlite3
5
+ /db/*.sqlite3-journal
6
+ /db/*.sqlite3-[0-9]*
7
+ /public/system
8
+ /coverage/
9
+ /spec/tmp
10
+ *.orig
11
+ rerun.txt
12
+ pickle-email-*.html
13
13
 
14
14
  # Ignore all logfiles and tempfiles.
15
15
  /log/*
@@ -17,24 +17,54 @@
17
17
  !/log/.keep
18
18
  !/tmp/.keep
19
19
 
20
- # Ignore pidfiles, but keep the directory.
21
- /tmp/pids/*
22
- !/tmp/pids/
23
- !/tmp/pids/.keep
20
+ # TODO Comment out this rule if you are OK with secrets being uploaded to the repo
21
+ config/initializers/secret_token.rb
22
+ config/master.key
24
23
 
25
- # Ignore storage (uploaded files in development and any SQLite databases).
26
- /storage/*
27
- !/storage/.keep
28
- /tmp/storage/*
29
- !/tmp/storage/
30
- !/tmp/storage/.keep
24
+ # Only include if you have production secrets in this file, which is no longer a Rails default
25
+ # config/secrets.yml
31
26
 
32
- /public/assets
27
+ # dotenv, dotenv-rails
28
+ # TODO Comment out these rules if environment variables can be committed
29
+ .env
30
+ .env*.local
31
+
32
+ ## Environment normalization:
33
+ /.bundle
34
+ /vendor/bundle
35
+
36
+ # these should all be checked in to normalize the environment:
37
+ # Gemfile.lock, .ruby-version, .ruby-gemset
33
38
 
34
- # Ignore master key for decrypting credentials and more.
35
- /config/master.key
39
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
40
+ .rvmrc
36
41
 
37
- /app/assets/builds/*
38
- !/app/assets/builds/.keep
42
+ # if using bower-rails ignore default bower_components path bower.json files
43
+ /vendor/assets/bower_components
44
+ *.bowerrc
45
+ bower.json
39
46
 
40
- /node_modules
47
+ # Ignore pow environment settings
48
+ .powenv
49
+
50
+ # Ignore Byebug command history file.
51
+ .byebug_history
52
+
53
+ # Ignore node_modules
54
+ node_modules/
55
+
56
+ # Ignore precompiled javascript packs
57
+ /public/packs
58
+ /public/packs-test
59
+ /public/assets
60
+
61
+ # Ignore yarn files
62
+ /yarn-error.log
63
+ yarn-debug.log*
64
+ .yarn-integrity
65
+
66
+ # Ignore uploaded files in development
67
+ /storage/*
68
+ !/storage/.keep
69
+ /public/uploads
70
+ /node_modules/