Sha256: eb1e61dd9ef161d36d75d9b738df6f3b1494323916ae595862bfde2194136a75

Contents?: true

Size: 523 Bytes

Versions: 3

Compression:

Stored size: 523 Bytes

Contents

module MaticJWT
  module Grape
    module Middleware
      class Request
        AUTHORIZATION_KEYS = %w[HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION].freeze

        def initialize(env)
          @env = env
        end

        def valid?
          !@env[auth_key].nil?
        end

        def auth_token
          @env[auth_key]
        end

        private

        def auth_key
          @authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.key?(key) }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
matic-jwt-1.2.1 lib/matic-jwt/grape/middleware/request.rb
matic-jwt-1.2.0 lib/matic-jwt/grape/middleware/request.rb
matic-jwt-1.1.0 lib/matic-jwt/grape/middleware/request.rb