Sha256: e0d297d120934e66678c6e883e6f8dbd5a6ec2e4376e72bb00184607ca94e576
Contents?: true
Size: 870 Bytes
Versions: 19
Compression:
Stored size: 870 Bytes
Contents
require "sinatra/authorization" 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
19 entries across 19 versions & 6 rubygems