zaikio-oauth_client 0.20.0 → 0.21.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e87deb46aa5f12ce0383be80478beeada52d8281dbc299570b6c0d7cd321068
|
4
|
+
data.tar.gz: 27dff67fdf8d1f02b12a28b490c1ee0b59b8832e20550608c2147d83920a9688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25045bb111f6373f883601e6c93fc05527630f9f5b5df09c2c9f937f41c7b789a26ffd3fcba803466be7cf9d1e9e58bd26c23992175eb22fcb0a98910a7ea0eb
|
7
|
+
data.tar.gz: 34bc3884461e5650d9a168d9a73d521040a349b6a99ea0e35d988e14629b7a94d642622928425128421c17b685291d6cd6aac9ce369b84471e637f90e7f20d0a
|
data/README.md
CHANGED
@@ -95,7 +95,7 @@ Then run `bundle install`.
|
|
95
95
|
Configure sidekiq scheduler in `config/sidekiq.yml`:
|
96
96
|
```yaml
|
97
97
|
:schedule:
|
98
|
-
|
98
|
+
cleanup_access_tokens_job:
|
99
99
|
cron: '0 3 * * *' # This will delete all expired tokens every day at 3am.
|
100
100
|
class: 'Zaikio::CleanupAccessTokensJob'
|
101
101
|
```
|
@@ -162,7 +162,7 @@ end
|
|
162
162
|
|
163
163
|
You can then use `Current.user` anywhere.
|
164
164
|
|
165
|
-
For **logout** use: `zaikio_oauth_client.session_path, method: :delete` or build your own controller for deleting the cookie.
|
165
|
+
For **logout** use: `zaikio_oauth_client.session_path, method: :delete` or build your own controller for deleting the cookie. If you do build your own controller, please be aware that it is possible for the access token to be nil, and you should handle this accordingly.
|
166
166
|
|
167
167
|
#### Multiple clients
|
168
168
|
|
@@ -1,23 +1,27 @@
|
|
1
1
|
module Zaikio
|
2
2
|
module OAuthClient
|
3
3
|
class SubscriptionsController < ConnectionsController
|
4
|
-
def new
|
5
|
-
opts = params.permit(:client_name, :state, :plan, :organization_id)
|
4
|
+
def new # rubocop:disable Metrics/MethodLength
|
5
|
+
opts = params.permit(:client_name, :state, :plan, :organization_id, :app_name, :redirect_uri)
|
6
6
|
opts[:state] ||= session[:state] = SecureRandom.urlsafe_base64(32)
|
7
7
|
|
8
8
|
plan = opts.delete(:plan)
|
9
9
|
organization_id = opts.delete(:organization_id)
|
10
|
+
app_name = opts.delete(:app_name)
|
11
|
+
redirect_uri = opts.delete(:redirect_uri)
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
scope = "Org.subscription_create"
|
14
|
+
scope_with_org_id = "Org/#{organization_id}.subscription_create"
|
15
|
+
subscription_scope = if app_name.present?
|
16
|
+
organization_id.present? ? "#{scope_with_org_id}_#{app_name}" : "#{scope}_#{app_name}"
|
13
17
|
else
|
14
|
-
|
18
|
+
organization_id.present? ? scope_with_org_id : scope
|
15
19
|
end
|
16
20
|
|
17
21
|
subscription_scope << ".#{plan}" if plan.present?
|
18
22
|
|
19
23
|
redirect_to oauth_client.auth_code.authorize_url(
|
20
|
-
redirect_uri: approve_url(opts.delete(:client_name)),
|
24
|
+
redirect_uri: redirect_uri || approve_url(opts.delete(:client_name)),
|
21
25
|
scope: subscription_scope,
|
22
26
|
**opts
|
23
27
|
), allow_other_host: true
|
data/lib/zaikio/oauth_client.rb
CHANGED
@@ -8,8 +8,6 @@ require "zaikio/oauth_client/authenticatable"
|
|
8
8
|
module Zaikio
|
9
9
|
module OAuthClient # rubocop:disable Metrics/ModuleLength
|
10
10
|
class << self
|
11
|
-
attr_reader :client_name
|
12
|
-
|
13
11
|
def configure
|
14
12
|
@configuration ||= Configuration.new
|
15
13
|
yield(configuration)
|
@@ -19,6 +17,14 @@ module Zaikio
|
|
19
17
|
@configuration ||= Configuration.new
|
20
18
|
end
|
21
19
|
|
20
|
+
def client_name
|
21
|
+
Thread.current[:zaikio_oauth_client_name]
|
22
|
+
end
|
23
|
+
|
24
|
+
def client_name=(new_value)
|
25
|
+
Thread.current[:zaikio_oauth_client_name] = new_value
|
26
|
+
end
|
27
|
+
|
22
28
|
def for(client_name = nil)
|
23
29
|
client_config_for(client_name).oauth_client
|
24
30
|
end
|
@@ -34,12 +40,14 @@ module Zaikio
|
|
34
40
|
@oauth_scheme = :request_body
|
35
41
|
end
|
36
42
|
|
37
|
-
def with_client(
|
38
|
-
original_client_name =
|
39
|
-
|
43
|
+
def with_client(new_client_name)
|
44
|
+
original_client_name = client_name
|
45
|
+
|
46
|
+
self.client_name = new_client_name
|
47
|
+
|
40
48
|
yield
|
41
49
|
ensure
|
42
|
-
|
50
|
+
self.client_name = original_client_name
|
43
51
|
end
|
44
52
|
|
45
53
|
def with_auth(options_or_access_token, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-oauth_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaikio GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|