Sha256: 97b194e9886a2a473319d799f8d2e00b9eeaaaf7673f1da4646f49dbbc377c8a
Contents?: true
Size: 807 Bytes
Versions: 7
Compression:
Stored size: 807 Bytes
Contents
require 'rest-core/middleware' class RestCore::AuthBasic def self.members; [:username, :password]; end include RestCore::Middleware def call env if username(env) if password(env) app.call(env.merge(REQUEST_HEADERS => auth_basic_header(env).merge(env[REQUEST_HEADERS] || {}))) else app.call(log(env, "AuthBasic: username provided: #{username(env)}," \ " but password is missing.")) end elsif password(env) app.call(log(env, "AuthBasic: password provided: #{password(env)}," \ " but username is missing.")) else app.call(env) end end def auth_basic_header env {'Authorization' => "Basic #{["#{username(env)}:#{password(env)}"].pack('m').tr("\n",'')}"} end end
Version data entries
7 entries across 7 versions & 1 rubygems