Sha256: be8884c6369e9f9b112a12d0d0ed8c69ab2a2504b4e3ad16abb9cdcfd6abf493
Contents?: true
Size: 798 Bytes
Versions: 1
Compression:
Stored size: 798 Bytes
Contents
module DcmgrGui class AuthServer < Sinatra::Base use Rack::MethodOverride def protected! unless authorized? response['WWW-Authenticate'] = %(Basic realm="Wakame dcmgr authorization.") throw(:halt, [401, "Not authorized.\n"]) end end def authorized? @auth ||= Rack::Auth::Basic::Request.new(request.env) (@auth.provided? && @auth.basic? && credentials = @auth.credentials) || ( return FALSE ) User.authenticate(credentials[0], credentials[1]) end # Neither nginx nor this server removes '..' from the path... get '/auth/*' do protected! command = /\/auth\/(.*)/.match(request.path_info)[1] headers 'X-Accel-Redirect' => "/dcmgr_cmd/#{command}" "auth response to '#{command}'" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wakame-vdc-webui-10.12.0 | app/api/auth_server.rb |