Sha256: 8b86d7ca727357e4598e10549c2a16d3e3c74b695492ee094d2fde4edf6b2d3f

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

module Diesel
  module Middleware
    module Auth
      class OAuth2

        AUTHORIZATION_HEADER = 'Authorization'
        AUTHORIZATION_HEADER_FORMAT = 'Bearer %s'

        def initialize(app, options)
          @app = app
          @id = options[:id]
        end

        def call(env)
          context = env[:context]
          auth_options = context.options[@id]
          env[:request_headers][AUTHORIZATION_HEADER] = AUTHORIZATION_HEADER_FORMAT % auth_options[:token]
          @app.call(env)
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
diesel-api-dsl-0.1.2 lib/diesel/middleware/auth/oauth2.rb
diesel-api-dsl-0.1.1 lib/diesel/middleware/auth/oauth2.rb