same_site_cookie_fix 0.0.2 → 0.1.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: a413baf7674d3f16b4ee58b1880ac5efc1ea1c926cfc60c18ae5a9907049b915
4
- data.tar.gz: 0adc0973d57676ba51cbeeb505e20663dbbed79c88b015b7d8d96010c9a0c789
3
+ metadata.gz: be012039c123a6c9e3c941345a1d7fa923c6de19df187aa3fff0ccc065b1fefd
4
+ data.tar.gz: 02a876f0e92a5b06d7cddfe1156f116dd1304751214cd6db75d7046cfd02e063
5
5
  SHA512:
6
- metadata.gz: 5dfc95e764d22d592b7b2e95a6e44a9b577936bfa1296d868c1aeb33358b637c12f39454a8781f1a90f718e40cdec13e2b86bfc94bc5f63b919b1491676d58ee
7
- data.tar.gz: 2c9ca628c56ca58d36c593c23c9838695f31dd2caf213d3266676d964520e570ac7ac83da5deac91f177e44ce6faafce0323b36a28c4fdf84921cc9b088509de
6
+ metadata.gz: ae106227703478774276db58fe5d23d46445aafc99d635a3d1ed3670f8d6c3f7fbbf0c75cf6a398365bb9ad627e4787f56a557c92a719c5b3c30422277f18344
7
+ data.tar.gz: 2bdaef832c38b39714a99382ae5c0cca2762cac5f8696fded23f5a7fc0f99820371aa80275c59765bfb8eb826be19046b8b53fbd958c7d3f190e23b1cb615039
@@ -0,0 +1,23 @@
1
+ module SameSiteCookieFix
2
+ class Helpers
3
+
4
+ SHOPIFY_APP_VERSION_WITH_SAMESITE_FIX = '11.6.0'.freeze
5
+
6
+ def self.should_load_railtie?
7
+ rails_is_defined? && !(shopify_app_is_defined? && shopify_app_has_samesite_fix?)
8
+ end
9
+
10
+ def self.rails_is_defined?
11
+ defined?(Rails)
12
+ end
13
+
14
+ def self.shopify_app_is_defined?
15
+ defined?(ShopifyApp)
16
+ end
17
+
18
+ def self.shopify_app_has_samesite_fix?
19
+ Gem::Version.new(ShopifyApp::VERSION) >= Gem::Version.new(SHOPIFY_APP_VERSION_WITH_SAMESITE_FIX)
20
+ end
21
+
22
+ end
23
+ end
@@ -1,3 +1,5 @@
1
+ require 'browser_sniffer'
2
+
1
3
  module SameSiteCookieFix
2
4
  class Middleware
3
5
  def initialize(app)
@@ -14,7 +16,7 @@ module SameSiteCookieFix
14
16
 
15
17
  cookies.each do |cookie|
16
18
  unless cookie.include?("; SameSite")
17
- headers['Set-Cookie'] = headers['Set-Cookie'].gsub("#{cookie}", "#{cookie}; secure; SameSite=None\n")
19
+ headers['Set-Cookie'] = headers['Set-Cookie'].gsub("#{cookie}", "#{cookie}; secure; SameSite=None")
18
20
  end
19
21
  end
20
22
  end
@@ -1,7 +1,7 @@
1
1
  module SameSiteCookieFix
2
2
  class Railtie < Rails::Railtie
3
3
  initializer "same_site_cookie_fix.railtie.configure_rails_initialization" do |app|
4
- app.middleware.use SameSiteCookieFix::Middleware
4
+ app.middleware.insert_before(ActionDispatch::Cookies, SameSiteCookieFix::Middleware)
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  module SameSiteCookieFix
2
2
 
3
- VERSION = '0.0.2'.freeze
3
+ VERSION = '0.1.0'.freeze
4
4
 
5
5
  end
@@ -1,5 +1,7 @@
1
1
  require 'same_site_cookie_fix/version'
2
- require 'same_site_cookie_fix/railtie' if defined?(Rails)
2
+ require 'same_site_cookie_fix/middleware'
3
+ require 'same_site_cookie_fix/helpers'
4
+ require 'same_site_cookie_fix/railtie' if SameSiteCookieFix::Helpers.should_load_railtie?
3
5
 
4
6
  module SameSiteCookieFix
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: same_site_cookie_fix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Ballard
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/same_site_cookie_fix.rb
35
+ - lib/same_site_cookie_fix/helpers.rb
35
36
  - lib/same_site_cookie_fix/middleware.rb
36
37
  - lib/same_site_cookie_fix/railtie.rb
37
38
  - lib/same_site_cookie_fix/version.rb