Module: Sorcery::Controller::Adapters::Sinatra::SorceryHelpers

Defined in:
lib/sorcery/controller/adapters/sinatra.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_with_http_basic {|@auth.credentials| ... } ⇒ Object

Yields:

  • (@auth.credentials)


49
50
51
52
# File 'lib/sorcery/controller/adapters/sinatra.rb', line 49

def authenticate_with_http_basic(&blk)
  @auth ||= Rack::Auth::Basic::Request.new(request.env)
  yield @auth.credentials if (@auth.provided? && @auth.basic? && @auth.credentials)
end

#request_http_basic_authentication(realm) ⇒ Object



44
45
46
47
# File 'lib/sorcery/controller/adapters/sinatra.rb', line 44

def request_http_basic_authentication(realm)
  response.header['WWW-Authenticate'] = %(Basic realm="#{realm}")
  response.status = 401
end