clerk-sdk-ruby 2.4.0 → 2.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -0
- data/lib/clerk/rack_middleware_v2.rb +23 -0
- data/lib/clerk/version.rb +1 -1
- data/lib/clerk.rb +24 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70d13c92fd01f471cd31373b72a5c4aa73784cbc4f8259dff001ed54d6bd5b0
|
4
|
+
data.tar.gz: 4d63622da821f4bdca7eaff4efa7d698c7666b8068f0de5add37b309e28e9dd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ce27dae71ef8f6e6335981041f40881273dc106e06973b288a1c9a089bf35bc03eaa9f561f6c4ca7b21431d7707043365fc77c8306241a85e5e60cd87667d5a
|
7
|
+
data.tar.gz: 8fc64101a4bde21a7ce0e137b395125554150a48bb7c93b83d595b106be7d0eb92b40d299685e98623f35f022a623bdcf6f2818dacd488d91f600aa32200a899
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## unreleased
|
2
2
|
|
3
|
+
## 2.5.0 - 2022-09-20
|
4
|
+
|
5
|
+
- feat: Add support for disabling the middleware on specific routes [https://github.com/clerkinc/clerk-sdk-ruby/pull/19]
|
6
|
+
|
7
|
+
## 2.4.0 - 2022-09-05
|
8
|
+
|
9
|
+
- feat: Add support for the users.disable_mfa endpoint
|
10
|
+
|
3
11
|
## 2.3.0 - 2022-08-30
|
4
12
|
|
5
13
|
- feat: Add support for the users.verify_password endpoint
|
data/README.md
CHANGED
@@ -82,6 +82,7 @@ Clerk.configure do |c|
|
|
82
82
|
c.base_url = "https://..." # if omitted: "https://api.clerk.dev/v1/"
|
83
83
|
c.logger = Logger.new(STDOUT) # if omitted, no logging
|
84
84
|
c.middleware_cache_store = ActiveSupport::Cache::FileStore.new("/tmp/clerk_middleware_cache") # if omitted: no caching
|
85
|
+
c.excluded_routes ["/foo", "/bar/*"]
|
85
86
|
end
|
86
87
|
```
|
87
88
|
|
@@ -60,11 +60,34 @@ module Clerk
|
|
60
60
|
class RackMiddlewareV2
|
61
61
|
def initialize(app)
|
62
62
|
@app = app
|
63
|
+
@excluded_routes = {}
|
64
|
+
@excluded_routes_wildcards = []
|
65
|
+
|
66
|
+
Clerk.configuration.excluded_routes.each do |route|
|
67
|
+
route = route.strip
|
68
|
+
|
69
|
+
if route.ends_with?("/*")
|
70
|
+
@excluded_routes_wildcards << route[0..-2]
|
71
|
+
else
|
72
|
+
@excluded_routes[route] = true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
@excluded_routes_wildcards.uniq!
|
63
77
|
end
|
64
78
|
|
65
79
|
def call(env)
|
66
80
|
env = env
|
67
81
|
req = Rack::Request.new(env)
|
82
|
+
|
83
|
+
if @excluded_routes[req.path]
|
84
|
+
return @app.call(env)
|
85
|
+
end
|
86
|
+
|
87
|
+
@excluded_routes_wildcards.each do |route|
|
88
|
+
return @app.call(env) if req.path.starts_with?(route)
|
89
|
+
end
|
90
|
+
|
68
91
|
env["clerk"] = Clerk::ProxyV2.new
|
69
92
|
header_token = req.env["HTTP_AUTHORIZATION"]
|
70
93
|
header_token = header_token.strip.sub(/\ABearer /, '') if header_token
|
data/lib/clerk/version.rb
CHANGED
data/lib/clerk.rb
CHANGED
@@ -18,9 +18,33 @@ module Clerk
|
|
18
18
|
PRODUCTION_BASE_URL = "https://api.clerk.dev/v1/".freeze
|
19
19
|
attr_accessor :api_key, :base_url, :logger, :middleware_cache_store
|
20
20
|
|
21
|
+
# An array of route paths on which the middleware will not execute.
|
22
|
+
#
|
23
|
+
# Only request paths that match _exactly_ one of the routes will be skipped.
|
24
|
+
# As a special case, if a route ends with '/*', then all request paths that
|
25
|
+
# match the route's prefix will be skipped.
|
26
|
+
#
|
27
|
+
# For example, given the following configuration:
|
28
|
+
#
|
29
|
+
# excluded_routes = ["/foo", "/bar/*"]
|
30
|
+
#
|
31
|
+
# the following requests will be excluded:
|
32
|
+
#
|
33
|
+
# - /foo
|
34
|
+
# - /bar/baz
|
35
|
+
# - /bar/abc/xyz
|
36
|
+
#
|
37
|
+
# while the following requests will NOT be excluded:
|
38
|
+
#
|
39
|
+
# - /foo/bar
|
40
|
+
# - /bar
|
41
|
+
#
|
42
|
+
attr_accessor :excluded_routes
|
43
|
+
|
21
44
|
def initialize
|
22
45
|
@base_url = ENV.fetch("CLERK_API_BASE", PRODUCTION_BASE_URL)
|
23
46
|
@api_key = ENV["CLERK_API_KEY"]
|
47
|
+
@excluded_routes = []
|
24
48
|
end
|
25
49
|
end
|
26
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clerk-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clerk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
rubygems_version: 3.2.
|
130
|
+
rubygems_version: 3.2.5
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Clerk SDK for Ruby.
|