Sha256: 28585904317be1ba5234fac8825ab01310bf5fc634607c3c7ab8977ac74777ba

Contents?: true

Size: 1005 Bytes

Versions: 4

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true

module SecureNative
  module Frameworks
    class Hanami
      SECURENATIVE_COOKIE = '_sn'

      def self.get_client_token(request)
        begin
          request.env[SECURENATIVE_COOKIE]
        rescue StandardError
          begin
            request.cookies[SECURENATIVE_COOKIE]
          rescue StandardError
            nil
          end
        end
      end

      def self.get_url(request)
        begin
          request.env['REQUEST_PATH']
        rescue StandardError
          nil
        end
      end

      def self.get_method(request)
        begin
          request.request_method
        rescue StandardError
          nil
        end
      end

      def self.get_headers(request)
        begin
          # Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
          { 'user-agent' => request.env['HTTP_USER_AGENT'] }
        rescue StandardError
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
securenative-0.1.33 lib/securenative/frameworks/hanami.rb
securenative-0.1.32 lib/securenative/frameworks/hanami.rb
securenative-0.1.31 lib/securenative/frameworks/hanami.rb
securenative-0.1.30 lib/securenative/frameworks/hanami.rb