zaikio-oauth_client 0.15.1 → 0.17.2

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: '058e2e4770f5b40f128b95bd51c4b873f9beb81f4e646aad5b68d26db88929ba'
4
- data.tar.gz: 5992b68e2ecf23a11b1fb17d018cf7364310c12dd528f927c00d116898fe28aa
3
+ metadata.gz: 605b297bfe708d26eb51ed1060bf243fc3060fd27df8f4ec481dcf94a471fcc2
4
+ data.tar.gz: 839bb62b7d00b272978fa3f225bd7416a7c12cf7508e4ab2242183fcb7c8d801
5
5
  SHA512:
6
- metadata.gz: f20de72870d6fa6365c6a1f74e9e65c6509cb7930f5ad2af1e77cabc8e8d3c1b87a71a1785703eb6352523476e47939f8894bf7628679cdd059cc4a421327028
7
- data.tar.gz: 81e593760b1664a5d15694544017cb9ad20ba9390c3d7b57d49c7bc2b18a2604d018c6f4bfa202a5ba16828116e5521102b0ae246fb30e4e18e8f6fcf07fb704
6
+ metadata.gz: 2c7e04798b1ca7338e30005794e2d804a90633816323f678bd2f9a7bcb7f9b8f368e3e68ac38490c44bf48761db785169f41e8f9cf22ce7cdee7b40b82e5ee05
7
+ data.tar.gz: 189afa394a1a0739d5a4ed60ed4fc667ee8aed698329fb7eb87cc6785bfc88ee610028d9b5fb4ac8ba389c399104e8956c8656ce0a4bbb1132b039f6b1612446
@@ -5,6 +5,10 @@ module Zaikio
5
5
 
6
6
  private
7
7
 
8
+ def new_path(options = {})
9
+ zaikio_oauth_client.new_connection_path(options)
10
+ end
11
+
8
12
  def approve_url(client_name = nil)
9
13
  zaikio_oauth_client.approve_connection_url(client_name)
10
14
  end
@@ -20,7 +20,7 @@ module Zaikio
20
20
  redirect_uri: approve_url(opts.delete(:client_name)),
21
21
  scope: subscription_scope,
22
22
  **opts
23
- )
23
+ ), allow_other_host: true
24
24
  end
25
25
  end
26
26
  end
@@ -63,7 +63,7 @@ module Zaikio
63
63
  end
64
64
 
65
65
  def bearer_klass
66
- return unless Zaikio.const_defined?("Hub::Models", false)
66
+ return unless Zaikio.const_defined?("Hub::Models", false) # rubocop:disable Performance/StringIdentifierArgument
67
67
 
68
68
  if Zaikio::Hub::Models.configuration.respond_to?(:"#{bearer_type.underscore}_class_name")
69
69
  Zaikio::Hub::Models.configuration.public_send(:"#{bearer_type.underscore}_class_name").constantize
@@ -4,7 +4,8 @@ module Zaikio
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def new
7
- opts = params.permit(:client_name, :show_signup, :prompt, :force_login, :state, :lang)
7
+ opts = params.permit(:client_name, :show_signup, :prompt, :prompt_email_confirmation,
8
+ :force_login, :state, :lang)
8
9
  opts[:lang] ||= I18n.locale if defined?(I18n)
9
10
  client_name = opts.delete(:client_name)
10
11
  opts[:state] ||= session[:state] = SecureRandom.urlsafe_base64(32)
@@ -13,10 +14,10 @@ module Zaikio
13
14
  redirect_uri: approve_url(client_name),
14
15
  scope: oauth_scope,
15
16
  **opts
16
- )
17
+ ), allow_other_host: true
17
18
  end
18
19
 
19
- def approve # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
20
+ def approve # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
20
21
  if params[:error].present?
21
22
  redirect_to send(
22
23
  respond_to?(:error_path_for) ? :error_path_for : :default_error_path_for,
@@ -36,6 +37,7 @@ module Zaikio
36
37
 
37
38
  origin = session[:origin]
38
39
  session.delete(:origin)
40
+ session.delete(:oauth_attempts)
39
41
 
40
42
  session[:zaikio_access_token_id] = access_token.id unless access_token.organization?
41
43
 
@@ -43,6 +45,13 @@ module Zaikio
43
45
  respond_to?(:after_approve_path_for) ? :after_approve_path_for : :default_after_approve_path_for,
44
46
  access_token, origin
45
47
  )
48
+ rescue OAuth2::Error => e
49
+ raise e unless e.code == "invalid_grant" || e.code == "invalid_request"
50
+ raise e if session[:oauth_attempts].to_i >= 3
51
+
52
+ session[:oauth_attempts] = session[:oauth_attempts].to_i + 1
53
+
54
+ redirect_to new_path(client_name: params[:client_name])
46
55
  end
47
56
 
48
57
  def destroy
@@ -58,6 +67,10 @@ module Zaikio
58
67
 
59
68
  private
60
69
 
70
+ def new_path(options = {})
71
+ zaikio_oauth_client.new_session_path(options)
72
+ end
73
+
61
74
  def approve_url(client_name = nil)
62
75
  zaikio_oauth_client.approve_session_url(client_name)
63
76
  end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.15.1".freeze
3
+ VERSION = "0.17.2".freeze
4
4
  end
5
5
  end
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.15.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-20 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack