kinde_sdk 1.1.0 → 1.1.1
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/README.md +14 -6
- data/lib/kinde_sdk/client.rb +0 -4
- data/lib/kinde_sdk/version.rb +1 -1
- data/lib/kinde_sdk.rb +4 -7
- data/spec/kinde_sdk_spec.rb +26 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3166fc3f21315cb21235d7c303440266daef8b2d4b37d983e2bc06bb28fd5acd
|
4
|
+
data.tar.gz: 7421f7964d90a458b47724a4073711480a6caeac1cc6fe3e68989dfbe2045821
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 380bac0d796adc5daf5b55faea19d130e32fc248b2e2fb5f91e0e74bb267b4ac617fb1f51163ce2871a0c78ed2447161a8be316f972a20d694dfd9a665b9fb2c
|
7
|
+
data.tar.gz: d667129a0d21dca7dd07baecedc96e78470eb0952744c7921e2bdb96445524bb378eef2625c99c87b6357ff1183b44e32e1df93fea1f05bf518bb926f53a51d8
|
data/README.md
CHANGED
@@ -239,15 +239,23 @@ instance_client.create_user(args)
|
|
239
239
|
```
|
240
240
|
|
241
241
|
#### Logout
|
242
|
-
For logout you need to call:
|
242
|
+
For logout you need to call (in case of rails app) in your controller:
|
243
243
|
```ruby
|
244
|
-
|
245
|
-
|
246
|
-
|
244
|
+
redirect_to KindeSdk.logout_url, allow_other_host: true
|
245
|
+
```
|
246
|
+
Your app should handle logout callback url (which was configured separately).
|
247
|
+
After calling redirect to logout_url (if set), Kinde redirect it back to logout callback path, where you need to clear your session:
|
248
|
+
```ruby
|
249
|
+
# .......
|
250
|
+
def logout_callback
|
251
|
+
Rails.logger.info("logout callback successfully received")
|
252
|
+
reset_session
|
253
|
+
redirect_to root_path
|
254
|
+
end
|
255
|
+
# ......
|
247
256
|
```
|
248
|
-
then clear your session or storage (delete your token) and redirect wherever you want to.
|
249
257
|
If you configured logout redirect url correct (e.g. added in the admin panel allowed logout redirect), you can receive
|
250
|
-
a logout callback.
|
258
|
+
a logout callback. Otherwise Kinde logout message will be shown.
|
251
259
|
|
252
260
|
### Organizations
|
253
261
|
#### Create an organization
|
data/lib/kinde_sdk/client.rb
CHANGED
@@ -30,10 +30,6 @@ module KindeSdk
|
|
30
30
|
get_claim("permissions").include?(permission)
|
31
31
|
end
|
32
32
|
|
33
|
-
def logout
|
34
|
-
KindeSdk.logout(bearer_token, kinde_api_client)
|
35
|
-
end
|
36
|
-
|
37
33
|
::KindeApi.constants.filter { |klass| klass.to_s.end_with?("Api") }.each do |klass|
|
38
34
|
api_klass = Kernel.const_get("KindeApi::#{klass}")
|
39
35
|
|
data/lib/kinde_sdk/version.rb
CHANGED
data/lib/kinde_sdk.rb
CHANGED
@@ -56,13 +56,10 @@ module KindeSdk
|
|
56
56
|
KindeSdk::Client.new(sdk_api_client, bearer_token)
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
query_params: { 'redirect' => @config.logout_url },
|
64
|
-
header_params: { 'Authorization' => "Bearer #{bearer_token}" }
|
65
|
-
)
|
59
|
+
def logout_url
|
60
|
+
query = @config.logout_url ? URI.encode_www_form(redirect: @config.logout_url) : nil
|
61
|
+
host = URI::parse(@config.domain).host
|
62
|
+
URI::HTTP.build(host: host, path: '/logout', query: query).to_s
|
66
63
|
end
|
67
64
|
|
68
65
|
def client_credentials_access(
|
data/spec/kinde_sdk_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe KindeSdk do
|
|
5
5
|
let(:client_id) { "client_id" }
|
6
6
|
let(:client_secret) { "client_secret" }
|
7
7
|
let(:callback_url) { "http://localhost:3000/callback" }
|
8
|
+
let(:logout_url) { "http://localhost/logout-callback" }
|
8
9
|
|
9
10
|
before do
|
10
11
|
KindeSdk.configure do |c|
|
@@ -12,6 +13,7 @@ describe KindeSdk do
|
|
12
13
|
c.client_id = client_id
|
13
14
|
c.client_secret = client_secret
|
14
15
|
c.callback_url = callback_url
|
16
|
+
c.logout_url = logout_url
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -23,6 +25,20 @@ describe KindeSdk do
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
28
|
+
describe "#logout_url" do
|
29
|
+
it "returns logout url" do
|
30
|
+
expect(described_class.logout_url)
|
31
|
+
.to eq("http://example.com/logout?redirect=http%3A%2F%2Flocalhost%2Flogout-callback")
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when logout url not set" do
|
35
|
+
let(:logout_url) { nil }
|
36
|
+
it "returns logout url without redirect query" do
|
37
|
+
expect(described_class.logout_url).to eq("http://example.com/logout")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
26
42
|
describe "#api_client" do
|
27
43
|
it "returns initialized api_client instance of KindeApi" do
|
28
44
|
expect(described_class.api_client("bearer-token")).to be_instance_of(KindeApi::ApiClient)
|
@@ -59,16 +75,16 @@ describe KindeSdk do
|
|
59
75
|
describe "client" do
|
60
76
|
let(:hash_to_encode) do
|
61
77
|
{ "aud" => [],
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
78
|
+
"azp" => "19ebb687cd2f405c9f2daf645a8db895",
|
79
|
+
"exp" => 1679600554,
|
80
|
+
"feature_flags" => nil,
|
81
|
+
"iat" => 1679514154,
|
82
|
+
"iss" => "https://example.kinde.com",
|
83
|
+
"jti" => "22c48b2c-da46-4661-a7ff-425c23eceab5",
|
84
|
+
"org_code" => "org_cb4544175bc",
|
85
|
+
"permissions" => ["read:todos", "create:todos"],
|
86
|
+
"scp" => ["openid", "offline"],
|
87
|
+
"sub" => "kp:b17adf719f7d4b87b611d1a88a09fd15" }
|
72
88
|
end
|
73
89
|
let(:token) { JWT.encode(hash_to_encode, nil, "none") }
|
74
90
|
let(:client) { described_class.client(token) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinde_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinde Australia Pty Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|