clerk-sdk-ruby 4.0.0.beta3 → 4.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +3 -0
- data/.github/workflows/main.yml +22 -14
- data/.gitignore +7 -1
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +26 -3
- data/Gemfile.lock +269 -13
- data/Guardfile +14 -0
- data/README.md +71 -11
- data/Rakefile +50 -6
- data/apps/rack/app.rb +67 -0
- data/apps/rack/config.ru +17 -0
- data/apps/rack/middleware/disable_paths.rb +13 -0
- data/apps/rails-api/.dockerignore +41 -0
- data/apps/rails-api/.gitattributes +9 -0
- data/apps/rails-api/.gitignore +32 -0
- data/apps/rails-api/.kamal/hooks/docker-setup.sample +3 -0
- data/apps/rails-api/.kamal/hooks/post-deploy.sample +14 -0
- data/apps/rails-api/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/apps/rails-api/.kamal/hooks/pre-build.sample +51 -0
- data/apps/rails-api/.kamal/hooks/pre-connect.sample +47 -0
- data/apps/rails-api/.kamal/hooks/pre-deploy.sample +109 -0
- data/apps/rails-api/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/apps/rails-api/.kamal/secrets +17 -0
- data/apps/rails-api/.rubocop.yml +8 -0
- data/apps/rails-api/.ruby-version +1 -0
- data/apps/rails-api/Dockerfile +69 -0
- data/apps/rails-api/Gemfile +54 -0
- data/apps/rails-api/Gemfile.lock +374 -0
- data/apps/rails-api/README.md +24 -0
- data/apps/rails-api/Rakefile +6 -0
- data/apps/rails-api/app/controllers/application_controller.rb +3 -0
- data/apps/rails-api/app/controllers/home_controller.rb +5 -0
- data/apps/rails-api/app/jobs/application_job.rb +7 -0
- data/apps/rails-api/app/mailers/application_mailer.rb +4 -0
- data/apps/rails-api/app/models/application_record.rb +3 -0
- data/apps/rails-api/app/views/layouts/mailer.html.erb +13 -0
- data/apps/rails-api/app/views/layouts/mailer.text.erb +1 -0
- data/apps/rails-api/bin/brakeman +7 -0
- data/apps/rails-api/bin/bundle +109 -0
- data/apps/rails-api/bin/dev +2 -0
- data/apps/rails-api/bin/docker-entrypoint +14 -0
- data/apps/rails-api/bin/jobs +6 -0
- data/apps/rails-api/bin/kamal +27 -0
- data/apps/rails-api/bin/rails +4 -0
- data/apps/rails-api/bin/rake +4 -0
- data/apps/rails-api/bin/rubocop +8 -0
- data/apps/rails-api/bin/setup +34 -0
- data/apps/rails-api/bin/thrust +5 -0
- data/apps/rails-api/config/application.rb +36 -0
- data/apps/rails-api/config/boot.rb +4 -0
- data/apps/rails-api/config/cable.yml +17 -0
- data/apps/rails-api/config/cache.yml +16 -0
- data/apps/rails-api/config/credentials.yml.enc +1 -0
- data/apps/rails-api/config/database.yml +41 -0
- data/apps/rails-api/config/deploy.yml +116 -0
- data/apps/rails-api/config/environment.rb +5 -0
- data/apps/rails-api/config/environments/development.rb +70 -0
- data/apps/rails-api/config/environments/production.rb +88 -0
- data/apps/rails-api/config/environments/test.rb +53 -0
- data/apps/rails-api/config/initializers/cors.rb +16 -0
- data/apps/rails-api/config/initializers/filter_parameter_logging.rb +8 -0
- data/apps/rails-api/config/initializers/inflections.rb +16 -0
- data/apps/rails-api/config/locales/en.yml +31 -0
- data/apps/rails-api/config/puma.rb +41 -0
- data/apps/rails-api/config/queue.yml +18 -0
- data/apps/rails-api/config/recurring.yml +10 -0
- data/apps/rails-api/config/routes.rb +10 -0
- data/apps/rails-api/config/storage.yml +34 -0
- data/apps/rails-api/config.ru +6 -0
- data/apps/rails-api/db/cable_schema.rb +11 -0
- data/apps/rails-api/db/cache_schema.rb +14 -0
- data/apps/rails-api/db/queue_schema.rb +129 -0
- data/apps/rails-api/db/seeds.rb +9 -0
- data/apps/rails-api/public/robots.txt +1 -0
- data/apps/rails-api/test/controllers/home_controller_test.rb +7 -0
- data/apps/rails-api/test/test_helper.rb +15 -0
- data/apps/rails-full/.dockerignore +47 -0
- data/apps/rails-full/.gitattributes +9 -0
- data/apps/rails-full/.gitignore +34 -0
- data/apps/rails-full/.kamal/hooks/docker-setup.sample +3 -0
- data/apps/rails-full/.kamal/hooks/post-deploy.sample +14 -0
- data/apps/rails-full/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/apps/rails-full/.kamal/hooks/pre-build.sample +51 -0
- data/apps/rails-full/.kamal/hooks/pre-connect.sample +47 -0
- data/apps/rails-full/.kamal/hooks/pre-deploy.sample +109 -0
- data/apps/rails-full/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/apps/rails-full/.kamal/secrets +17 -0
- data/apps/rails-full/.rubocop.yml +8 -0
- data/apps/rails-full/.ruby-version +1 -0
- data/apps/rails-full/Dockerfile +72 -0
- data/apps/rails-full/Gemfile +70 -0
- data/apps/rails-full/Gemfile.lock +429 -0
- data/apps/rails-full/README.md +24 -0
- data/apps/rails-full/Rakefile +6 -0
- data/apps/rails-full/app/assets/stylesheets/application.css +10 -0
- data/apps/rails-full/app/controllers/application_controller.rb +6 -0
- data/apps/rails-full/app/controllers/home_controller.rb +11 -0
- data/apps/rails-full/app/helpers/application_helper.rb +2 -0
- data/apps/rails-full/app/helpers/home_helper.rb +2 -0
- data/apps/rails-full/app/javascript/application.js +3 -0
- data/apps/rails-full/app/javascript/controllers/application.js +9 -0
- data/apps/rails-full/app/javascript/controllers/hello_controller.js +7 -0
- data/apps/rails-full/app/javascript/controllers/index.js +4 -0
- data/apps/rails-full/app/jobs/application_job.rb +7 -0
- data/apps/rails-full/app/mailers/application_mailer.rb +4 -0
- data/apps/rails-full/app/models/application_record.rb +3 -0
- data/apps/rails-full/app/views/home/index.html.erb +7 -0
- data/apps/rails-full/app/views/layouts/application.html.erb +60 -0
- data/apps/rails-full/app/views/layouts/mailer.html.erb +13 -0
- data/apps/rails-full/app/views/layouts/mailer.text.erb +1 -0
- data/apps/rails-full/app/views/pwa/manifest.json.erb +22 -0
- data/apps/rails-full/app/views/pwa/service-worker.js +26 -0
- data/apps/rails-full/bin/brakeman +7 -0
- data/apps/rails-full/bin/bundle +109 -0
- data/apps/rails-full/bin/dev +2 -0
- data/apps/rails-full/bin/docker-entrypoint +14 -0
- data/apps/rails-full/bin/importmap +4 -0
- data/apps/rails-full/bin/jobs +6 -0
- data/apps/rails-full/bin/kamal +27 -0
- data/apps/rails-full/bin/rails +4 -0
- data/apps/rails-full/bin/rake +4 -0
- data/apps/rails-full/bin/rubocop +8 -0
- data/apps/rails-full/bin/setup +34 -0
- data/apps/rails-full/bin/thrust +5 -0
- data/apps/rails-full/config/application.rb +31 -0
- data/apps/rails-full/config/boot.rb +4 -0
- data/apps/rails-full/config/cable.yml +17 -0
- data/apps/rails-full/config/cache.yml +16 -0
- data/apps/rails-full/config/credentials.yml.enc +1 -0
- data/apps/rails-full/config/database.yml +41 -0
- data/apps/rails-full/config/deploy.yml +116 -0
- data/apps/rails-full/config/environment.rb +5 -0
- data/apps/rails-full/config/environments/development.rb +72 -0
- data/apps/rails-full/config/environments/production.rb +91 -0
- data/apps/rails-full/config/environments/test.rb +53 -0
- data/apps/rails-full/config/importmap.rb +7 -0
- data/apps/rails-full/config/initializers/assets.rb +7 -0
- data/apps/rails-full/config/initializers/clerk.rb +4 -0
- data/apps/rails-full/config/initializers/content_security_policy.rb +25 -0
- data/apps/rails-full/config/initializers/filter_parameter_logging.rb +8 -0
- data/apps/rails-full/config/initializers/inflections.rb +16 -0
- data/apps/rails-full/config/locales/en.yml +31 -0
- data/apps/rails-full/config/puma.rb +41 -0
- data/apps/rails-full/config/queue.yml +18 -0
- data/apps/rails-full/config/recurring.yml +10 -0
- data/apps/rails-full/config/routes.rb +15 -0
- data/apps/rails-full/config/storage.yml +34 -0
- data/apps/rails-full/config.ru +6 -0
- data/apps/rails-full/db/cable_schema.rb +11 -0
- data/apps/rails-full/db/cache_schema.rb +14 -0
- data/apps/rails-full/db/queue_schema.rb +129 -0
- data/apps/rails-full/db/seeds.rb +9 -0
- data/apps/rails-full/public/400.html +114 -0
- data/apps/rails-full/public/404.html +114 -0
- data/apps/rails-full/public/406-unsupported-browser.html +114 -0
- data/apps/rails-full/public/422.html +114 -0
- data/apps/rails-full/public/500.html +114 -0
- data/apps/rails-full/public/icon.png +0 -0
- data/apps/rails-full/public/icon.svg +3 -0
- data/apps/rails-full/public/robots.txt +1 -0
- data/apps/rails-full/test/application_system_test_case.rb +5 -0
- data/apps/rails-full/test/controllers/home_controller_test.rb +7 -0
- data/apps/rails-full/test/test_helper.rb +15 -0
- data/apps/sinatra/app.rb +29 -0
- data/apps/sinatra/config.ru +2 -0
- data/apps/sinatra/views/index.erb +44 -0
- data/clerk-sdk-ruby.gemspec +2 -1
- data/lib/clerk/authenticatable.rb +14 -79
- data/lib/clerk/authenticate_context.rb +164 -181
- data/lib/clerk/authenticate_request.rb +238 -230
- data/lib/clerk/configuration.rb +78 -0
- data/lib/clerk/constants.rb +68 -46
- data/lib/clerk/error.rb +17 -0
- data/lib/clerk/jwks_cache.rb +27 -22
- data/lib/clerk/proxy.rb +135 -0
- data/lib/clerk/rack.rb +2 -0
- data/lib/clerk/rack_middleware.rb +88 -73
- data/lib/clerk/rails.rb +3 -0
- data/lib/clerk/railtie.rb +7 -6
- data/lib/clerk/sdk.rb +46 -156
- data/lib/clerk/sinatra.rb +52 -0
- data/lib/clerk/utils.rb +52 -6
- data/lib/clerk/version.rb +1 -1
- data/lib/clerk.rb +15 -51
- metadata +187 -25
- data/CODEOWNERS +0 -1
- data/lib/clerk/errors.rb +0 -22
- data/lib/clerk/rack_middleware_v2.rb +0 -167
- data/lib/clerk/resources/allowlist.rb +0 -16
- data/lib/clerk/resources/allowlist_identifiers.rb +0 -16
- data/lib/clerk/resources/clients.rb +0 -23
- data/lib/clerk/resources/email_addresses.rb +0 -17
- data/lib/clerk/resources/emails.rb +0 -16
- data/lib/clerk/resources/jwks.rb +0 -18
- data/lib/clerk/resources/organizations.rb +0 -73
- data/lib/clerk/resources/phone_numbers.rb +0 -17
- data/lib/clerk/resources/plural_resource.rb +0 -38
- data/lib/clerk/resources/sessions.rb +0 -26
- data/lib/clerk/resources/singular_resource.rb +0 -14
- data/lib/clerk/resources/users.rb +0 -37
- data/lib/clerk/resources.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d37c25f76ef78179a59083af8a754d1dbdff353d858cda3ba08ae679497ff8
|
4
|
+
data.tar.gz: f3d5676522601c297a8a7ba997bb73072aefe5cb387ab0a8e836d991421f61ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96891456fd52907105030582cb772c28f07a3ca24d16ddd666277df514652314cdaa3ba54ee14e99466789aea996dad74df884ca2a9c0ff6d7ff42d5ad22a404
|
7
|
+
data.tar.gz: 4512bbdb1d3e6e787adb7fd7dfa39967fef73d6e742fcf0ca5c87f58016e5ed5ed25c3fd32c24dc24997644b388da33ca6da7e1ed028cb61040dec60210bd43c
|
data/.env.example
ADDED
data/.github/workflows/main.yml
CHANGED
@@ -1,20 +1,28 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
4
8
|
|
5
9
|
jobs:
|
6
|
-
|
10
|
+
test:
|
7
11
|
runs-on: ubuntu-latest
|
12
|
+
name: Ruby ${{ matrix.ruby }}
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- "3.3.5"
|
8
17
|
steps:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
ruby-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
CLERK_PUBLISHABLE_KEY: 'pk_test_ZXhhbXBsZS5jb20k'
|
18
|
+
- name: Checkout
|
19
|
+
uses: actions/checkout@v4
|
20
|
+
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
|
27
|
+
- name: Unit Tests
|
28
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 4.0.0.beta4 - 2025-01-06
|
2
|
+
|
3
|
+
[BREAKING] This release introduces our new `clerk-http-client` gem, which is a generated directly from the Clerk API OpenAPI specs. This will help to ensure that the SDK is always in sync with the Clerk API.
|
4
|
+
|
5
|
+
- feat: Add support for the `clerk-http-client` gem [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
6
|
+
- feat: Add support for Revalidation [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
7
|
+
- feat: Add support for Rails API mode [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
8
|
+
- feat: Add support for Sinatra [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
9
|
+
- feat: Middleware cache defaults to `Rails.cache` -> `ActiveSupport::Cache::MemoryStore` (if available) -> no caching [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
10
|
+
- chore: Refactor Clerk helper methods for Rails and Rack [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
11
|
+
- fix: Update configuration naming of `api_key` to `secret_key` [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
12
|
+
- docs: Add example applications for Rails, Sinatra, and Rack under `apps/` [https://github.com/clerk/clerk-sdk-ruby/pull/77]
|
13
|
+
|
1
14
|
## 4.0.0.beta3 - 2024-04-02
|
2
15
|
|
3
16
|
- fix: Make publishable_key and secret_key required without making the envs required [https://github.com/clerk/clerk-sdk-ruby/pull/53]
|
@@ -16,6 +29,15 @@ Note: this is identical to 4.0.0.beta1, which was yanked because it was not gene
|
|
16
29
|
- chore: re-organize and refactor internal code to extract functionality of rack middleware [https://github.com/clerk/clerk-sdk-ruby/pull/45]
|
17
30
|
- changed: `CLERK_PUBLISHABLE_KEY` or `publishable_key` in `Clerk.configure` is **required** [https://github.com/clerk/clerk-sdk-ruby/pull/46]
|
18
31
|
|
32
|
+
## 3.2.0 - 2024-04-08
|
33
|
+
|
34
|
+
- fix: Infinite redirect loop when client_uat=0 and __session exists [https://github.com/clerk/clerk-sdk-ruby/pull/55]
|
35
|
+
|
36
|
+
## 3.1.0 - 2024-03-19
|
37
|
+
|
38
|
+
- fix: Incompatible __client_uat & __session should show interstitial [https://github.com/clerk/clerk-sdk-ruby/pull/51]
|
39
|
+
- fix: Incorrect check that lead to infinite redirect loop introduced by [https://github.com/clerk/clerk-sdk-ruby/pull/51]
|
40
|
+
|
19
41
|
## 3.0.0 - 2024-01-09
|
20
42
|
|
21
43
|
Note: this is identical to 2.12.0, which was yanked because it contained a
|
data/Gemfile
CHANGED
@@ -2,9 +2,32 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in clerk
|
5
|
+
# Specify your gem's dependencies in clerk.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
8
|
+
group :development do
|
9
|
+
gem "activesupport", "~> 8.0", require: false
|
10
|
+
gem "dotenv", "~> 3.1", require: false
|
11
|
+
gem "puma", "~> 6.4", ">= 6.4.3", require: false
|
12
|
+
gem "rack", "~> 3.1", ">= 3.1.8", require: false
|
13
|
+
gem "rbs", "~> 3.6"
|
14
|
+
gem "rake", "~> 13.0"
|
15
|
+
gem "rackup", "~> 2.2", require: false
|
16
|
+
gem "rb-fsevent", "~> 0.11", ">= 0.11.2", platform: [:ruby], require: false
|
17
|
+
gem "rerun", "~> 0.14", require: false
|
18
|
+
gem "sinatra", "~> 4.1", require: false
|
19
|
+
gem "standard", "~> 1.42"
|
20
|
+
gem "wdm", "~> 0.2", platform: [:mswin, :windows]
|
21
|
+
end
|
9
22
|
|
10
|
-
|
23
|
+
group :development, :test do
|
24
|
+
gem "rspec", "~> 3.0"
|
25
|
+
gem "rspec-rails", "~> 7.1"
|
26
|
+
gem "guard-rspec", "~> 4.7", require: false
|
27
|
+
gem "guard-rake", "~> 1.0", require: false
|
28
|
+
end
|
29
|
+
|
30
|
+
group :test do
|
31
|
+
gem "simplecov", require: false
|
32
|
+
gem "climate_control", require: false
|
33
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
clerk-sdk-ruby (4.0.0.
|
4
|
+
clerk-sdk-ruby (4.0.0.beta4)
|
5
|
+
clerk-http-client (~> 0.0.1)
|
5
6
|
concurrent-ruby (~> 1.1)
|
6
7
|
faraday (>= 1.4.1, < 3.0)
|
7
8
|
jwt (~> 2.5)
|
@@ -9,31 +10,286 @@ PATH
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
|
13
|
+
actionpack (8.0.1)
|
14
|
+
actionview (= 8.0.1)
|
15
|
+
activesupport (= 8.0.1)
|
16
|
+
nokogiri (>= 1.8.5)
|
17
|
+
rack (>= 2.2.4)
|
18
|
+
rack-session (>= 1.0.1)
|
19
|
+
rack-test (>= 0.6.3)
|
20
|
+
rails-dom-testing (~> 2.2)
|
21
|
+
rails-html-sanitizer (~> 1.6)
|
22
|
+
useragent (~> 0.16)
|
23
|
+
actionview (8.0.1)
|
24
|
+
activesupport (= 8.0.1)
|
25
|
+
builder (~> 3.1)
|
26
|
+
erubi (~> 1.11)
|
27
|
+
rails-dom-testing (~> 2.2)
|
28
|
+
rails-html-sanitizer (~> 1.6)
|
29
|
+
activesupport (8.0.1)
|
30
|
+
base64
|
31
|
+
benchmark (>= 0.3)
|
32
|
+
bigdecimal
|
33
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
34
|
+
connection_pool (>= 2.2.5)
|
35
|
+
drb
|
36
|
+
i18n (>= 1.6, < 2)
|
37
|
+
logger (>= 1.4.2)
|
38
|
+
minitest (>= 5.1)
|
39
|
+
securerandom (>= 0.3)
|
40
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
41
|
+
uri (>= 0.13.1)
|
42
|
+
ast (2.4.2)
|
43
|
+
base64 (0.2.0)
|
44
|
+
benchmark (0.4.0)
|
45
|
+
bigdecimal (3.1.9)
|
46
|
+
builder (3.3.0)
|
13
47
|
byebug (11.1.3)
|
14
|
-
|
15
|
-
|
48
|
+
clerk-http-client (0.0.1)
|
49
|
+
faraday (>= 1.0.1, < 3.0)
|
50
|
+
faraday-multipart
|
51
|
+
marcel
|
52
|
+
climate_control (1.2.0)
|
53
|
+
coderay (1.1.3)
|
54
|
+
concurrent-ruby (1.3.4)
|
55
|
+
connection_pool (2.4.1)
|
56
|
+
crass (1.0.6)
|
57
|
+
date (3.4.1)
|
58
|
+
diff-lcs (1.5.1)
|
59
|
+
docile (1.4.1)
|
60
|
+
dotenv (3.1.7)
|
61
|
+
drb (2.2.1)
|
62
|
+
erubi (1.13.1)
|
63
|
+
faraday (2.12.2)
|
64
|
+
faraday-net_http (>= 2.0, < 3.5)
|
65
|
+
json
|
66
|
+
logger
|
67
|
+
faraday-multipart (1.1.0)
|
68
|
+
multipart-post (~> 2.0)
|
69
|
+
faraday-net_http (3.4.0)
|
70
|
+
net-http (>= 0.5.0)
|
71
|
+
ffi (1.17.1-arm64-darwin)
|
72
|
+
ffi (1.17.1-x86_64-linux-gnu)
|
73
|
+
formatador (1.1.0)
|
74
|
+
guard (2.19.1)
|
75
|
+
formatador (>= 0.2.4)
|
76
|
+
listen (>= 2.7, < 4.0)
|
77
|
+
logger (~> 1.6)
|
78
|
+
lumberjack (>= 1.0.12, < 2.0)
|
79
|
+
nenv (~> 0.1)
|
80
|
+
notiffany (~> 0.0)
|
81
|
+
ostruct (~> 0.6)
|
82
|
+
pry (>= 0.13.0)
|
83
|
+
shellany (~> 0.0)
|
84
|
+
thor (>= 0.18.1)
|
85
|
+
guard-compat (1.2.1)
|
86
|
+
guard-rake (1.0.0)
|
87
|
+
guard
|
88
|
+
rake
|
89
|
+
guard-rspec (4.7.3)
|
90
|
+
guard (~> 2.1)
|
91
|
+
guard-compat (~> 1.1)
|
92
|
+
rspec (>= 2.99.0, < 4.0)
|
93
|
+
i18n (1.14.6)
|
94
|
+
concurrent-ruby (~> 1.0)
|
95
|
+
io-console (0.8.0)
|
96
|
+
irb (1.14.3)
|
97
|
+
rdoc (>= 4.0.0)
|
98
|
+
reline (>= 0.4.2)
|
99
|
+
json (2.9.1)
|
100
|
+
jwt (2.10.1)
|
16
101
|
base64
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
102
|
+
language_server-protocol (3.17.0.3)
|
103
|
+
lint_roller (1.1.0)
|
104
|
+
listen (3.9.0)
|
105
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
106
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
107
|
+
logger (1.6.4)
|
108
|
+
loofah (2.24.0)
|
109
|
+
crass (~> 1.0.2)
|
110
|
+
nokogiri (>= 1.12.0)
|
111
|
+
lumberjack (1.2.10)
|
112
|
+
marcel (1.0.4)
|
113
|
+
method_source (1.1.0)
|
114
|
+
minitest (5.25.4)
|
115
|
+
multipart-post (2.4.1)
|
116
|
+
mustermann (3.0.3)
|
117
|
+
ruby2_keywords (~> 0.0.1)
|
118
|
+
nenv (0.3.0)
|
119
|
+
net-http (0.6.0)
|
120
|
+
uri
|
121
|
+
nio4r (2.7.4)
|
122
|
+
nokogiri (1.18.1-arm64-darwin)
|
123
|
+
racc (~> 1.4)
|
124
|
+
nokogiri (1.18.1-x86_64-darwin)
|
125
|
+
racc (~> 1.4)
|
126
|
+
nokogiri (1.18.1-x86_64-linux-gnu)
|
127
|
+
racc (~> 1.4)
|
128
|
+
notiffany (0.1.3)
|
129
|
+
nenv (~> 0.1)
|
130
|
+
shellany (~> 0.0)
|
131
|
+
ostruct (0.6.1)
|
132
|
+
parallel (1.26.3)
|
133
|
+
parser (3.3.6.0)
|
134
|
+
ast (~> 2.4.1)
|
135
|
+
racc
|
136
|
+
pry (0.15.2)
|
137
|
+
coderay (~> 1.1)
|
138
|
+
method_source (~> 1.0)
|
139
|
+
psych (5.2.2)
|
140
|
+
date
|
141
|
+
stringio
|
142
|
+
puma (6.5.0)
|
143
|
+
nio4r (~> 2.0)
|
144
|
+
racc (1.8.1)
|
145
|
+
rack (3.1.8)
|
146
|
+
rack-protection (4.1.1)
|
147
|
+
base64 (>= 0.1.0)
|
148
|
+
logger (>= 1.6.0)
|
149
|
+
rack (>= 3.0.0, < 4)
|
150
|
+
rack-session (2.1.0)
|
151
|
+
base64 (>= 0.1.0)
|
152
|
+
rack (>= 3.0.0)
|
153
|
+
rack-test (2.2.0)
|
154
|
+
rack (>= 1.3)
|
155
|
+
rackup (2.2.1)
|
156
|
+
rack (>= 3)
|
157
|
+
rails-dom-testing (2.2.0)
|
158
|
+
activesupport (>= 5.0.0)
|
159
|
+
minitest
|
160
|
+
nokogiri (>= 1.6)
|
161
|
+
rails-html-sanitizer (1.6.2)
|
162
|
+
loofah (~> 2.21)
|
163
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
164
|
+
railties (8.0.1)
|
165
|
+
actionpack (= 8.0.1)
|
166
|
+
activesupport (= 8.0.1)
|
167
|
+
irb (~> 1.13)
|
168
|
+
rackup (>= 1.0.0)
|
169
|
+
rake (>= 12.2)
|
170
|
+
thor (~> 1.0, >= 1.2.2)
|
171
|
+
zeitwerk (~> 2.6)
|
172
|
+
rainbow (3.1.1)
|
173
|
+
rake (13.2.1)
|
174
|
+
rb-fsevent (0.11.2)
|
175
|
+
rb-inotify (0.11.1)
|
176
|
+
ffi (~> 1.0)
|
177
|
+
rbs (3.8.1)
|
178
|
+
logger
|
179
|
+
rdoc (6.10.0)
|
180
|
+
psych (>= 4.0.0)
|
181
|
+
regexp_parser (2.10.0)
|
182
|
+
reline (0.6.0)
|
183
|
+
io-console (~> 0.5)
|
184
|
+
rerun (0.14.0)
|
185
|
+
listen (~> 3.0)
|
186
|
+
rspec (3.13.0)
|
187
|
+
rspec-core (~> 3.13.0)
|
188
|
+
rspec-expectations (~> 3.13.0)
|
189
|
+
rspec-mocks (~> 3.13.0)
|
190
|
+
rspec-core (3.13.2)
|
191
|
+
rspec-support (~> 3.13.0)
|
192
|
+
rspec-expectations (3.13.3)
|
193
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
194
|
+
rspec-support (~> 3.13.0)
|
195
|
+
rspec-mocks (3.13.2)
|
196
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
197
|
+
rspec-support (~> 3.13.0)
|
198
|
+
rspec-rails (7.1.0)
|
199
|
+
actionpack (>= 7.0)
|
200
|
+
activesupport (>= 7.0)
|
201
|
+
railties (>= 7.0)
|
202
|
+
rspec-core (~> 3.13)
|
203
|
+
rspec-expectations (~> 3.13)
|
204
|
+
rspec-mocks (~> 3.13)
|
205
|
+
rspec-support (~> 3.13)
|
206
|
+
rspec-support (3.13.2)
|
207
|
+
rubocop (1.69.2)
|
208
|
+
json (~> 2.3)
|
209
|
+
language_server-protocol (>= 3.17.0)
|
210
|
+
parallel (~> 1.10)
|
211
|
+
parser (>= 3.3.0.2)
|
212
|
+
rainbow (>= 2.2.2, < 4.0)
|
213
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
214
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
215
|
+
ruby-progressbar (~> 1.7)
|
216
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
217
|
+
rubocop-ast (1.37.0)
|
218
|
+
parser (>= 3.3.1.0)
|
219
|
+
rubocop-performance (1.23.1)
|
220
|
+
rubocop (>= 1.48.1, < 2.0)
|
221
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
222
|
+
ruby-progressbar (1.13.0)
|
23
223
|
ruby2_keywords (0.0.5)
|
24
|
-
|
224
|
+
securerandom (0.4.1)
|
225
|
+
shellany (0.0.1)
|
226
|
+
simplecov (0.22.0)
|
227
|
+
docile (~> 1.1)
|
228
|
+
simplecov-html (~> 0.11)
|
229
|
+
simplecov_json_formatter (~> 0.1)
|
230
|
+
simplecov-html (0.13.1)
|
231
|
+
simplecov_json_formatter (0.1.4)
|
232
|
+
sinatra (4.1.1)
|
233
|
+
logger (>= 1.6.0)
|
234
|
+
mustermann (~> 3.0)
|
235
|
+
rack (>= 3.0.0, < 4)
|
236
|
+
rack-protection (= 4.1.1)
|
237
|
+
rack-session (>= 2.0.0, < 3)
|
238
|
+
tilt (~> 2.0)
|
239
|
+
standard (1.43.0)
|
240
|
+
language_server-protocol (~> 3.17.0.2)
|
241
|
+
lint_roller (~> 1.0)
|
242
|
+
rubocop (~> 1.69.1)
|
243
|
+
standard-custom (~> 1.0.0)
|
244
|
+
standard-performance (~> 1.6)
|
245
|
+
standard-custom (1.0.2)
|
246
|
+
lint_roller (~> 1.0)
|
247
|
+
rubocop (~> 1.50)
|
248
|
+
standard-performance (1.6.0)
|
249
|
+
lint_roller (~> 1.1)
|
250
|
+
rubocop-performance (~> 1.23.0)
|
251
|
+
stringio (3.1.2)
|
252
|
+
thor (1.3.2)
|
253
|
+
tilt (2.5.0)
|
254
|
+
timecop (0.9.10)
|
255
|
+
tzinfo (2.0.6)
|
256
|
+
concurrent-ruby (~> 1.0)
|
257
|
+
unicode-display_width (3.1.3)
|
258
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
259
|
+
unicode-emoji (4.0.4)
|
260
|
+
uri (1.0.2)
|
261
|
+
useragent (0.16.11)
|
262
|
+
zeitwerk (2.7.1)
|
25
263
|
|
26
264
|
PLATFORMS
|
27
265
|
arm64-darwin-22
|
266
|
+
arm64-darwin-23
|
267
|
+
arm64-darwin-24
|
28
268
|
universal-darwin-21
|
29
269
|
x86_64-linux
|
30
270
|
|
31
271
|
DEPENDENCIES
|
272
|
+
activesupport (~> 8.0)
|
32
273
|
byebug (~> 11.1)
|
33
274
|
clerk-sdk-ruby!
|
34
|
-
|
275
|
+
climate_control
|
276
|
+
dotenv (~> 3.1)
|
277
|
+
guard-rake (~> 1.0)
|
278
|
+
guard-rspec (~> 4.7)
|
279
|
+
puma (~> 6.4, >= 6.4.3)
|
280
|
+
rack (~> 3.1, >= 3.1.8)
|
281
|
+
rackup (~> 2.2)
|
35
282
|
rake (~> 13.0)
|
283
|
+
rb-fsevent (~> 0.11, >= 0.11.2)
|
284
|
+
rbs (~> 3.6)
|
285
|
+
rerun (~> 0.14)
|
286
|
+
rspec (~> 3.0)
|
287
|
+
rspec-rails (~> 7.1)
|
288
|
+
simplecov
|
289
|
+
sinatra (~> 4.1)
|
290
|
+
standard (~> 1.42)
|
36
291
|
timecop (~> 0.9.4)
|
292
|
+
wdm (~> 0.2)
|
37
293
|
|
38
294
|
BUNDLED WITH
|
39
|
-
2.
|
295
|
+
2.6.2
|
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec", group: :spec do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
end
|
data/README.md
CHANGED
@@ -87,8 +87,7 @@ supported configuration settings their environment variable equivalents:
|
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
Clerk.configure do |c|
|
90
|
-
c.
|
91
|
-
c.base_url = "https://..." # if omitted: ENV["CLERK_API_BASE"] - defaults to "https://api.clerk.com/v1/"
|
90
|
+
c.secret_key = "sk_(test|live)_...." # if omitted: ENV["CLERK_SECRET_KEY"] - API calls will fail if unset
|
92
91
|
c.publishable_key = "pk_(test|live)_...." # if omitted: ENV["CLERK_PUBLISHABLE_KEY"] - Handshake mechanism (check section below) will fail if unset
|
93
92
|
c.logger = Logger.new(STDOUT) # if omitted, no logging
|
94
93
|
c.middleware_cache_store = ActiveSupport::Cache::FileStore.new("/tmp/clerk_middleware_cache") # if omitted: no caching
|
@@ -101,9 +100,8 @@ arguments to the constructor:
|
|
101
100
|
|
102
101
|
```ruby
|
103
102
|
clerk = Clerk::SDK.new(
|
104
|
-
api_key: "X",
|
105
|
-
base_url: "Y",
|
106
103
|
logger: Logger.new()
|
104
|
+
secret_key: "X",
|
107
105
|
)
|
108
106
|
```
|
109
107
|
|
@@ -126,6 +124,22 @@ of `Clerk::Proxy`. To get the session or the user of the session, you call
|
|
126
124
|
`session` or `user` respectively. In case there is no session, you can retrieve
|
127
125
|
the API error with the `error` getter method.
|
128
126
|
|
127
|
+
```ruby
|
128
|
+
use Clerk::Rack::Middleware
|
129
|
+
```
|
130
|
+
|
131
|
+
### Reverification middleware
|
132
|
+
|
133
|
+
The SDK comes with a revalidation middleware which will automatically revalidate the session when the user navigates to a protected route.
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
use Clerk::Rack::Reverification,
|
137
|
+
preset: Clerk::StepUp::Preset::LAX,
|
138
|
+
routes: ["/*"]
|
139
|
+
```
|
140
|
+
|
141
|
+
|
142
|
+
|
129
143
|
## Rails integration
|
130
144
|
|
131
145
|
The SDK will automatically add the [Rack middleware](#rack-middleware) to the
|
@@ -133,18 +147,55 @@ middleware stack. For easier access to the Clerk session and user, include the
|
|
133
147
|
`Clerk::Authenticatable` concern in your controller:
|
134
148
|
|
135
149
|
```ruby
|
136
|
-
require "clerk/authenticatable"
|
137
|
-
|
138
150
|
class ApplicationController < ActionController::Base
|
139
151
|
include Clerk::Authenticatable
|
140
152
|
end
|
153
|
+
|
154
|
+
class AdminController < ApplicationController
|
155
|
+
before_action :require_reverification!, only: [:protected]
|
156
|
+
|
157
|
+
def index
|
158
|
+
@user = clerk.user
|
159
|
+
end
|
160
|
+
|
161
|
+
def protected
|
162
|
+
render json: {message: clerk.user? ? "Valid session" : "Not logged in"}
|
163
|
+
end
|
164
|
+
end
|
141
165
|
```
|
142
166
|
|
143
|
-
This gives your controller and views access to the following methods:
|
167
|
+
This gives your controller and views access to the following methods and more:
|
168
|
+
|
169
|
+
- `clerk.session`
|
170
|
+
- `clerk.user`
|
171
|
+
- `clerk.user?`
|
172
|
+
|
173
|
+
## Sinatra integration
|
174
|
+
|
175
|
+
The SDK enables the use of Extensions to add Clerk support to your Sinatra application.
|
176
|
+
|
177
|
+
`Sinatra::Clerk` will automatically add the [Rack middleware](#rack-middleware)to the
|
178
|
+
middleware stack and enable easy access to the Clerk session and user helper methods.
|
144
179
|
|
145
|
-
|
146
|
-
|
147
|
-
|
180
|
+
```ruby
|
181
|
+
class App < Sinatra::Base
|
182
|
+
register Sinatra::Clerk
|
183
|
+
|
184
|
+
get "/" do
|
185
|
+
erb :index, format: :html5
|
186
|
+
end
|
187
|
+
|
188
|
+
get "/admin" do
|
189
|
+
@user = clerk.user
|
190
|
+
erb :index, format: :html5
|
191
|
+
end
|
192
|
+
|
193
|
+
get "/protected" do
|
194
|
+
require_reverification!
|
195
|
+
{message: clerk.user? ? "Valid session" : "Not logged in"}.to_json
|
196
|
+
end
|
197
|
+
end
|
198
|
+
```
|
148
199
|
|
149
200
|
## Internals
|
150
201
|
|
@@ -171,11 +222,20 @@ With the handshake, we can resolve the authentication state on the backend and e
|
|
171
222
|
## Development
|
172
223
|
|
173
224
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
174
|
-
`bundle exec rake` to run the tests. You can also run `bin/console` for an
|
225
|
+
`bundle exec rake spec` to run the tests. You can also run `bin/console` for an
|
175
226
|
interactive prompt that will allow you to experiment.
|
176
227
|
|
177
228
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
178
229
|
|
230
|
+
To run the example applications, run:
|
231
|
+
|
232
|
+
```bash
|
233
|
+
rake app:rack
|
234
|
+
rake app:rails
|
235
|
+
rake app:rails:api
|
236
|
+
rake app:sinatra
|
237
|
+
```
|
238
|
+
|
179
239
|
## Release
|
180
240
|
|
181
241
|
To release a new version:
|
data/Rakefile
CHANGED
@@ -1,12 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
-
require "rake
|
4
|
+
require "standard/rake"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
################################
|
7
|
+
# COVERAGE
|
8
|
+
################################
|
9
|
+
|
10
|
+
desc "Open coverage report"
|
11
|
+
task(:cov) { system "open coverage/index.html" }
|
12
|
+
|
13
|
+
################################
|
14
|
+
# TESTING
|
15
|
+
################################
|
16
|
+
|
17
|
+
desc "Run all tests"
|
18
|
+
task spec: "spec:all"
|
19
|
+
|
20
|
+
namespace :spec do
|
21
|
+
task(:all) { system "bundle exec rspec" }
|
22
|
+
|
23
|
+
desc "Run tests on file changes"
|
24
|
+
task(:watch) { system "bundle exec guard -g spec" }
|
25
|
+
|
26
|
+
desc "Run failed tests only"
|
27
|
+
task(:failed) { system "bundle exec rspec --only-failures" }
|
28
|
+
end
|
29
|
+
|
30
|
+
################################
|
31
|
+
# PLAYGROUND APPLICATIONS
|
32
|
+
################################
|
33
|
+
|
34
|
+
namespace :app do
|
35
|
+
desc "Run Rails (full stack) application"
|
36
|
+
task rails: "rails:full"
|
37
|
+
|
38
|
+
namespace :rails do
|
39
|
+
task :full do
|
40
|
+
cd ("apps/rails-full") { system "bin/rails server" }
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Run Rails (API only) application"
|
44
|
+
task :api do
|
45
|
+
cd ("apps/rails-api") { system "bin/rails server" }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Run Rack application"
|
50
|
+
task(:rack) { system "rerun --dir lib,apps/rack --pattern '**/*.{rb,ru}' -- bundle exec puma apps/rack/config.ru -p 3000" }
|
51
|
+
|
52
|
+
desc "Run Sinatra application"
|
53
|
+
task(:sinatra) { system "rerun --dir lib,apps/sinatra --pattern '**/*.{erb,rb,ru}' -- bundle exec puma apps/sinatra/config.ru -p 3000 -v" }
|
10
54
|
end
|
11
55
|
|
12
|
-
|
56
|
+
|