ruby_native 0.1.7 → 0.1.9

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: eddde0de797e27e33325a23bffdcbb2e12c0488f4560cfaa0178026ffa0dfcea
4
- data.tar.gz: ec4ac586194bddccedc3cc73093a79a450370d3587ce8f28eff4ecfcf81ec0ec
3
+ metadata.gz: 3c52e3d0cb2543e347993b2c283255755f368172641e92f51b4efa6c6f378e0d
4
+ data.tar.gz: 156a6454239c6a44bd3cb9ec8a02a1eef790633fb22621ab5ef258c18273ca1c
5
5
  SHA512:
6
- metadata.gz: 45c5cc73aa71badca636536a6442b92c9c06657a039dfd846f960c91b52e9be5ca29c43625b3e245fd0e179780bc0964fe743c4a55088b6debc1a6e76a62d288
7
- data.tar.gz: 27146b84641d802cdb506a44a965f5d4d1274501b25a5611d3ab6af6e950b5ac2ffffd5ad0549d4013f356301280c8a085e37a4c4424eb4c97226f0fee0161cf
6
+ metadata.gz: 1e19461f236c94227b11a68c0762bbfbb839e7e1ee08b4b71c397a522afd8b5992f86c1da81e143e7c66e2637844c8c71938722239a6d5c2016831cb42c5cc3e
7
+ data.tar.gz: ebdfe0f93a44a2d9efe1de997767648946cfa9d93306ebdb613e953ec5c25981c727dc4943857725a2e6806b4b032682cef503365182cd474df9b85d826b3c9d
@@ -14,12 +14,14 @@ module RubyNative
14
14
  # session cookie, which would overwrite the authenticated one.
15
15
  request.session_options[:skip] = true
16
16
 
17
- if data[:cookies].present?
18
- response.headers["set-cookie"] = data[:cookies].join("\n")
17
+ cookies = data[:cookies] || []
18
+
19
+ if cookies.present?
20
+ response.headers["set-cookie"] = cookies.join("\n")
19
21
  end
20
22
 
21
23
  Rails.logger.debug { "[RubyNative] OAuth token exchanged, redirecting to #{data[:redirect_url]}" }
22
- render json: {redirect_url: data[:redirect_url]}
24
+ redirect_to data[:redirect_url], allow_other_host: true
23
25
  end
24
26
  end
25
27
  end
@@ -8,14 +8,18 @@ module RubyNative
8
8
 
9
9
  def call(env)
10
10
  request = ActionDispatch::Request.new(env)
11
- started_oauth = oauth_start_request?(request)
12
- callback_scheme = request.params["callback_scheme"] if started_oauth
11
+ on_oauth_path = oauth_path?(request)
12
+ started_native_oauth = on_oauth_path && request.params["ruby_native"] == "1"
13
+ callback_scheme = request.params["callback_scheme"] if started_native_oauth
13
14
 
14
15
  status, headers, body = @app.call(env)
15
16
 
16
- if started_oauth && callback_scheme.present? && redirect?(status)
17
- Rails.logger.debug { "[RubyNative] OAuth started for #{request.path}, setting tracking cookie" }
17
+ if on_oauth_path && redirect?(status)
18
18
  relax_cookie_samesite!(headers)
19
+ end
20
+
21
+ if started_native_oauth && callback_scheme.present? && redirect?(status)
22
+ Rails.logger.debug { "[RubyNative] OAuth started for #{request.path}, setting tracking cookie" }
19
23
  set_cookie(headers, callback_scheme)
20
24
  end
21
25
 
@@ -66,9 +70,8 @@ module RubyNative
66
70
 
67
71
  private
68
72
 
69
- def oauth_start_request?(request)
70
- return false unless oauth_paths.any? { |p| request.path == p }
71
- request.params["ruby_native"] == "1"
73
+ def oauth_path?(request)
74
+ oauth_paths.any? { |p| request.path == p }
72
75
  end
73
76
 
74
77
  def set_cookie(headers, callback_scheme)
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti