zaikio-oauth_client 0.19.3 → 0.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58d2e1d10678b7eddb4afc7931c94e04299b63027c3b02c5773e03bf74b29b7d
4
- data.tar.gz: 44459fbc11ec98ccdd1f88819416f50b704a1d9f1a32a7a24d17a92b863563e9
3
+ metadata.gz: 24be71a3c75d9524e109cab652442d2a229ca14281a0fc3604256382eb01cf60
4
+ data.tar.gz: 3e289f86bbaa43b2d6dadfd6d239aef561e39376500cde3f560f9a5838dec851
5
5
  SHA512:
6
- metadata.gz: c4dd805f5c186d1d502afd9788b77ed7f9178672c841b03d7f9c5c97f81d5dc3243a255f1087f1e49bc312a024b4758df7599e871efcd650e34097527c927e51
7
- data.tar.gz: 025cfe46f4cdc9cb9138b814d86a82f3b7590a6fba2e1261bbe420ba6d16a43392eb88306500a02a2fa5cc3047a7970a24e7c6e28fc6bf91dcc6833554d5165a
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
- cleanup_acces_tokens_job:
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
- subscription_scope = if organization_id.present?
12
- "Org/#{organization_id}.subscription_create"
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
- "Org.subscription_create"
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
@@ -1,11 +1,13 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- module Authenticatable
3
+ module Authenticatable # rubocop:disable Metrics/ModuleLength
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def new
7
7
  opts = params.permit(:client_name, :show_signup, :prompt, :prompt_email_confirmation,
8
- :force_login, :state, :lang)
8
+ :force_login, :state, :lang,
9
+ person: %i[first_name name email],
10
+ organization: [:name, :country_code, { kinds: [] }])
9
11
  opts[:lang] ||= I18n.locale if defined?(I18n)
10
12
  client_name = opts.delete(:client_name)
11
13
  opts[:state] ||= session[:state] = SecureRandom.urlsafe_base64(32)
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.19.3".freeze
3
+ VERSION = "0.21.0".freeze
4
4
  end
5
5
  end
@@ -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(client_name)
38
- original_client_name = @client_name || nil
39
- @client_name = client_name
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
- @client_name = original_client_name
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.19.3
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-08-03 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack