clerk-sdk-ruby 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +22 -12
- data/docs/clerk-logo-dark.png +0 -0
- data/docs/clerk-logo-light.png +0 -0
- data/lib/clerk/rack_middleware_v2.rb +23 -0
- data/lib/clerk/resources/organizations.rb +65 -0
- data/lib/clerk/resources/users.rb +4 -0
- data/lib/clerk/resources.rb +1 -0
- data/lib/clerk/sdk.rb +5 -0
- data/lib/clerk/version.rb +1 -1
- data/lib/clerk.rb +24 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 487a2987f913d5c256ebad719075bbb121af707bc5e2419f12d886f4a7a643f2
|
4
|
+
data.tar.gz: 28af474ba5555c26fafb0f64e4969030f0b4fc56ca3df4db3faca0a3855fd5a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 307f730b9fa19db0e74954e33241f917699af10d876a8314d309366ff43930c7531d204d6c939003b18cee98d4189ffbd56bc8ea12ac1536e4b7d35be68f3057
|
7
|
+
data.tar.gz: eef7c69d6d233a80f4c4bbd2df328c9fa3ed74cdfaa0548f1200601d1e632906f403c89e6055698c8e092e9923344202501f742be5a183ea774b59ccaecb9143
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## unreleased
|
2
2
|
|
3
|
+
## 2.6.0 - 2022-11-01
|
4
|
+
|
5
|
+
- feat: Implement Organization endpoints [https://github.com/clerkinc/clerk-sdk-ruby/pull/20]
|
6
|
+
|
7
|
+
## 2.5.0 - 2022-09-20
|
8
|
+
|
9
|
+
- feat: Add support for disabling the middleware on specific routes [https://github.com/clerkinc/clerk-sdk-ruby/pull/19]
|
10
|
+
|
11
|
+
## 2.4.0 - 2022-09-05
|
12
|
+
|
13
|
+
- feat: Add support for the users.disable_mfa endpoint
|
14
|
+
|
3
15
|
## 2.3.0 - 2022-08-30
|
4
16
|
|
5
17
|
- feat: Add support for the users.verify_password endpoint
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,35 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://www.clerk.dev/?utm_source=github&utm_medium=starter_repos&utm_campaign=sdk_ruby" target="_blank" align="center">
|
3
|
+
<picture>
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="./docs/clerk-logo-dark.png">
|
5
|
+
<img src="./docs/clerk-logo-light.png" height="64">
|
6
|
+
</picture>
|
7
|
+
</a>
|
8
|
+
<br />
|
9
|
+
</p>
|
3
10
|
|
4
|
-
|
5
|
-
session & user management needs!
|
6
|
-
|
7
|
-
This SDK allows you to call the Clerk Backend API from Ruby code without having
|
8
|
-
to implement the calls yourself.
|
11
|
+
# Clerk Ruby SDK
|
9
12
|
|
10
|
-
|
11
|
-
v2](https://docs.clerk.dev/main-concepts/auth-v2).
|
13
|
+
This SDK allows you to call the [Clerk](https://www.clerk.dev/?utm_source=github&utm_medium=starter_repos&utm_campaign=sdk_ruby) Backend API from Ruby code without having to implement the calls yourself.
|
12
14
|
|
13
|
-
|
14
|
-
[
|
15
|
+
[![chat on Discord](https://img.shields.io/discord/856971667393609759.svg?logo=discord)](https://discord.com/invite/b5rXHjAg7A)
|
16
|
+
[![documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://docs.clerk.dev)
|
17
|
+
[![twitter](https://img.shields.io/twitter/follow/ClerkDev?style=social)](https://twitter.com/intent/follow?screen_name=ClerkDev)
|
15
18
|
|
16
19
|
---
|
17
20
|
|
18
21
|
**Clerk is Hiring!**
|
19
22
|
|
20
|
-
Would you like to work on Open Source software and help maintain this repository? Apply today
|
23
|
+
Would you like to work on Open Source software and help maintain this repository? [Apply today!](https://apply.workable.com/clerk-dev/)
|
21
24
|
|
22
25
|
---
|
23
26
|
|
27
|
+
**Note**: You're looking at the main branch, which requires that you use [Auth
|
28
|
+
v2](https://clerk.dev/docs/upgrade-guides/auth-v2).
|
29
|
+
|
30
|
+
If you're looking for the legacy authentication scheme, refer to the
|
31
|
+
[`v1`](https://github.com/clerkinc/clerk-sdk-ruby/tree/v1) branch.
|
32
|
+
|
24
33
|
## Installation
|
25
34
|
|
26
35
|
Add this line to your application's Gemfile:
|
@@ -82,6 +91,7 @@ Clerk.configure do |c|
|
|
82
91
|
c.base_url = "https://..." # if omitted: "https://api.clerk.dev/v1/"
|
83
92
|
c.logger = Logger.new(STDOUT) # if omitted, no logging
|
84
93
|
c.middleware_cache_store = ActiveSupport::Cache::FileStore.new("/tmp/clerk_middleware_cache") # if omitted: no caching
|
94
|
+
c.excluded_routes ["/foo", "/bar/*"]
|
85
95
|
end
|
86
96
|
```
|
87
97
|
|
Binary file
|
Binary file
|
@@ -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
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require_relative "plural_resource"
|
3
|
+
|
4
|
+
module Clerk
|
5
|
+
module Resources
|
6
|
+
class Organizations
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def initialize(client)
|
10
|
+
@client = client
|
11
|
+
@resource = PluralResource.new(client, "organizations")
|
12
|
+
end
|
13
|
+
|
14
|
+
def_delegators :@resource, :all, :find, :create, :update, :delete
|
15
|
+
|
16
|
+
#
|
17
|
+
# Invitations
|
18
|
+
#
|
19
|
+
def pending_invitations(org_id, query_params = {})
|
20
|
+
@client.request(:get, "#{invitations_path(org_id)}/pending", query: query_params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_invitation(org_id, data)
|
24
|
+
@client.request(:post, invitations_path(org_id), body: data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def revoke_invitation(org_id, invitation_id, data)
|
28
|
+
@client.request(:post, "#{invitations_path(org_id, invitation_id)}/revoke", body: data)
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Memberships
|
33
|
+
#
|
34
|
+
def memberships(org_id, query_params = {})
|
35
|
+
@client.request(:get, memberships_path(org_id), query: query_params)
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_membership(org_id, data)
|
39
|
+
@client.request(:post, memberships_path(org_id), body: data)
|
40
|
+
end
|
41
|
+
|
42
|
+
def update_membership(org_id, user_id, data)
|
43
|
+
@client.request(:patch, memberships_path(org_id, user_id), body: data)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete_membership(org_id, user_id)
|
47
|
+
@client.request(:delete, memberships_path(org_id, user_id))
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def invitations_path(org_id, invitation_id=nil)
|
53
|
+
path = "#{@resource.resource_path(org_id)}/invitations"
|
54
|
+
path << "/#{invitation_id}" if invitation_id
|
55
|
+
path
|
56
|
+
end
|
57
|
+
|
58
|
+
def memberships_path(org_id, user_id=nil)
|
59
|
+
path = "#{@resource.resource_path(org_id)}/memberships"
|
60
|
+
path << "/#{user_id}" if user_id
|
61
|
+
path
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -24,6 +24,10 @@ module Clerk
|
|
24
24
|
def disable_mfa(user_id)
|
25
25
|
@client.request(:delete, "#{@resource.resource_path(user_id)}/mfa")
|
26
26
|
end
|
27
|
+
|
28
|
+
def organization_memberships(user_id, query_params = {})
|
29
|
+
@client.request(:get, "#{@resource.resource_path(user_id)}/organization_memberships", query: query_params)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
data/lib/clerk/resources.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative "resources/allowlist_identifiers"
|
|
2
2
|
require_relative "resources/allowlist"
|
3
3
|
require_relative "resources/clients"
|
4
4
|
require_relative "resources/emails"
|
5
|
+
require_relative "resources/organizations"
|
5
6
|
require_relative "resources/sessions"
|
6
7
|
require_relative "resources/sms_messages"
|
7
8
|
require_relative "resources/users"
|
data/lib/clerk/sdk.rb
CHANGED
@@ -10,6 +10,7 @@ require_relative "resources/allowlist_identifiers"
|
|
10
10
|
require_relative "resources/allowlist"
|
11
11
|
require_relative "resources/clients"
|
12
12
|
require_relative "resources/emails"
|
13
|
+
require_relative "resources/organizations"
|
13
14
|
require_relative "resources/sessions"
|
14
15
|
require_relative "resources/sms_messages"
|
15
16
|
require_relative "resources/users"
|
@@ -114,6 +115,10 @@ module Clerk
|
|
114
115
|
Resources::Emails.new(self)
|
115
116
|
end
|
116
117
|
|
118
|
+
def organizations
|
119
|
+
Resources::Organizations.new(self)
|
120
|
+
end
|
121
|
+
|
117
122
|
def sessions
|
118
123
|
Resources::Sessions.new(self)
|
119
124
|
end
|
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.6.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-
|
11
|
+
date: 2022-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -84,6 +84,8 @@ files:
|
|
84
84
|
- bin/console
|
85
85
|
- bin/setup
|
86
86
|
- clerk-sdk-ruby.gemspec
|
87
|
+
- docs/clerk-logo-dark.png
|
88
|
+
- docs/clerk-logo-light.png
|
87
89
|
- lib/clerk.rb
|
88
90
|
- lib/clerk/authenticatable.rb
|
89
91
|
- lib/clerk/errors.rb
|
@@ -97,6 +99,7 @@ files:
|
|
97
99
|
- lib/clerk/resources/clients.rb
|
98
100
|
- lib/clerk/resources/emails.rb
|
99
101
|
- lib/clerk/resources/jwks.rb
|
102
|
+
- lib/clerk/resources/organizations.rb
|
100
103
|
- lib/clerk/resources/plural_resource.rb
|
101
104
|
- lib/clerk/resources/sessions.rb
|
102
105
|
- lib/clerk/resources/singular_resource.rb
|
@@ -127,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
130
|
- !ruby/object:Gem::Version
|
128
131
|
version: '0'
|
129
132
|
requirements: []
|
130
|
-
rubygems_version: 3.2.
|
133
|
+
rubygems_version: 3.2.5
|
131
134
|
signing_key:
|
132
135
|
specification_version: 4
|
133
136
|
summary: Clerk SDK for Ruby.
|