Sha256: 537a048a9469c98757ce34b6e0e4ca09654c8fb473608bc2d7a9200d97861627

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module SecureNative
  module Frameworks
    class Rails
      SECURENATIVE_COOKIE = '_sn'

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

      def self.get_url(request)
        begin
          # Rails >= 3.x
          request.fullpath
        rescue StandardError
          begin
            # Rails < 3.x & Sinatra
            request.url if url.nil?
          rescue StandardError
            nil
          end
        end
      end

      def self.get_method(request)
        begin
          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/rails.rb
securenative-0.1.32 lib/securenative/frameworks/rails.rb
securenative-0.1.31 lib/securenative/frameworks/rails.rb
securenative-0.1.30 lib/securenative/frameworks/rails.rb