Sha256: fd858b8ab6d7b6bc2a4ed39312832d9079882fdbd335039a2f5f52eba1c04c0b
Contents?: true
Size: 904 Bytes
Versions: 29
Compression:
Stored size: 904 Bytes
Contents
# frozen_string_literal: true module ShopifyApp class SameSiteCookieMiddleware COOKIE_SEPARATOR = "\n" def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) user_agent = env['HTTP_USER_AGENT'] if headers && headers['Set-Cookie'] && BrowserSniffer.new(user_agent).same_site_none_compatible? && ShopifyApp.configuration.enable_same_site_none && Rack::Request.new(env).ssl? set_cookies = headers['Set-Cookie'] .split(COOKIE_SEPARATOR) .compact .map do |cookie| cookie << '; Secure' unless cookie =~ /;\s*secure/i cookie << '; SameSite=None' unless cookie =~ /;\s*samesite=/i cookie end headers['Set-Cookie'] = set_cookies.join(COOKIE_SEPARATOR) end [status, headers, body] end end end
Version data entries
29 entries across 29 versions & 1 rubygems