Sha256: f6ccfe61623983f00bc276ec5894e4c513052a296cbc74088398519795545477
Contents?: true
Size: 742 Bytes
Versions: 7
Compression:
Stored size: 742 Bytes
Contents
module Apiture module Middleware module Auth class OAuth2 AUTHORIZATION_HEADER = 'Authorization'.freeze AUTHORIZATION_HEADER_FORMAT = 'Bearer %s'.freeze def initialize(app, options) @app = app @id = options[:id] @in = options[:in] @name = options[:name] end def call(env) context = env[:context] auth_options = context.options[@id] token = auth_options[:token] if @in == :query env[:params][@name] = token else env[:request_headers][AUTHORIZATION_HEADER] = AUTHORIZATION_HEADER_FORMAT % token end @app.call(env) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems