Module: Sinatra::Helpers

Defined in:
lib/sinatra/basic_auth.rb

Defined Under Namespace

Classes: Authentication

Instance Method Summary collapse

Instance Method Details

#require_basic_authObject



53
54
55
56
57
58
59
60
# File 'lib/sinatra/basic_auth.rb', line 53

def require_basic_auth
  a = Authentication.new( self, request )
  return if a.authorized?
  a.unauthorized! unless a.auth.provided?
  a.bad_request!  unless a.auth.basic?
  a.unauthorized! unless a.authorize( *a.auth.credentials )
  request.env['REMOTE_USER'] = a.auth.username
end