Sha256: cf1aa1dfa7aa77dd9870209a7bb1014ca5a3433a63cdad1396f6b0587dc6d091

Contents?: true

Size: 546 Bytes

Versions: 13

Compression:

Stored size: 546 Bytes

Contents

module Shieldify
  class Middleware
    class Authentication
      attr_reader :app

      def initialize(app)
        @app = app
      end

      def call(env)
        env['warden'].authenticate!(:email, :jwt)

        status, headers, response = app.call(env)
        headers = headers_with_token(env, headers)
        [status, headers, response]
      end

      private

      def headers_with_token(env, headers)
        token = env["auth.jwt"]
        headers['Authorization'] = "Bearer #{token}"
        headers
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shieldify-0.2.9.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.8.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.7.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.6.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.5.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.4.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.3.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.2.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.1.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.2.0.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.1.2.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.1.1.pre.alpha lib/shieldify/middleware/authentication.rb
shieldify-0.1.0.pre.alpha lib/shieldify/middleware/authentication.rb