Sha256: 058e22629a945d88065c42068ee16b0c6f6a4f54c6839b506b8ebd3f726c763f
Contents?: true
Size: 855 Bytes
Versions: 6
Compression:
Stored size: 855 Bytes
Contents
require "diddies" 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
6 entries across 6 versions & 4 rubygems