Sha256: 01357dc09990bb62d033d4443715059ffe31ebd0966da585fc0de162c97f00a6
Contents?: true
Size: 912 Bytes
Versions: 18
Compression:
Stored size: 912 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' if ShopifyApp.configuration.embedded_app? cookie end headers['Set-Cookie'] = set_cookies.join(COOKIE_SEPARATOR) end [status, headers, body] end end end
Version data entries
18 entries across 18 versions & 2 rubygems