Sha256: 1425eff7830139674efb193070021d56e721625fcf390f02b30e52fbe4879524
Contents?: true
Size: 864 Bytes
Versions: 9
Compression:
Stored size: 864 Bytes
Contents
require "sinatra/ditties" module Integrity module Helpers module Authorization include Sinatra::Authorization def authorization_realm "Integrity" end def authorized? return true unless Integrity.config[:use_basic_auth] !!request.env["REMOTE_USER"] end def authorize(user, password) if Integrity.config[:hash_admin_password] password = Digest::SHA1.hexdigest(password) end !Integrity.config[:use_basic_auth] || (Integrity.config[:admin_username] == user && Integrity.config[:admin_password] == password) end def unauthorized!(realm=authorization_realm) response["WWW-Authenticate"] = %(Basic realm="#{realm}") throw :halt, [401, show(:unauthorized, :title => "incorrect credentials")] end end end end
Version data entries
9 entries across 9 versions & 4 rubygems