same_site_cookie_fix 0.0.2 → 0.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be012039c123a6c9e3c941345a1d7fa923c6de19df187aa3fff0ccc065b1fefd
|
4
|
+
data.tar.gz: 02a876f0e92a5b06d7cddfe1156f116dd1304751214cd6db75d7046cfd02e063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
4
|
+
app.middleware.insert_before(ActionDispatch::Cookies, SameSiteCookieFix::Middleware)
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
data/lib/same_site_cookie_fix.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'same_site_cookie_fix/version'
|
2
|
-
require 'same_site_cookie_fix/
|
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
|
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
|