zaikio-oauth_client 0.20.0 → 0.21.0
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: 24be71a3c75d9524e109cab652442d2a229ca14281a0fc3604256382eb01cf60
|
4
|
+
data.tar.gz: 3e289f86bbaa43b2d6dadfd6d239aef561e39376500cde3f560f9a5838dec851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4caa7219b4ad019bd813dccc7939f8558122169fd8196edf6deedc720ae6554aba1f651ac69e5dc689ed7b6dcada682cd7bc0bb92353e49722116b179c54132c
|
7
|
+
data.tar.gz: 5a3501038b5471dd8018a71f4399892ecdc80c1fba4d30e3a6d332bfd624381463994ecef6de5575de7fff0c33a7a445add000c1b12155516e715cde9c133547
|
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
|
```
|
@@ -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.0
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|