Module: Integrity::Helpers::Authorization
- Includes:
- Sinatra::Authorization
- Included in:
- Integrity::Helpers
- Defined in:
- lib/integrity/helpers/authorization.rb
Instance Method Summary collapse
- #authorization_realm ⇒ Object
- #authorize(user, password) ⇒ Object
- #authorized? ⇒ Boolean
- #unauthorized!(realm = authorization_realm) ⇒ Object
Instance Method Details
#authorization_realm ⇒ Object
8 9 10 |
# File 'lib/integrity/helpers/authorization.rb', line 8 def "Integrity" end |
#authorize(user, password) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/integrity/helpers/authorization.rb', line 17 def (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 |
#authorized? ⇒ Boolean
12 13 14 15 |
# File 'lib/integrity/helpers/authorization.rb', line 12 def return true unless Integrity.config[:use_basic_auth] !!request.env["REMOTE_USER"] end |
#unauthorized!(realm = authorization_realm) ⇒ Object
27 28 29 30 |
# File 'lib/integrity/helpers/authorization.rb', line 27 def (realm=) response["WWW-Authenticate"] = %(Basic realm="#{realm}") throw :halt, [401, show(:unauthorized, :title => "incorrect credentials")] end |