Module: CASServer::Controllers

Defined in:
lib/casserver/controllers.rb

Defined Under Namespace

Classes: Login, LoginTicketDispenser, Logout, Proxy, ProxyValidate, ServiceValidate, Validate

Class Method Summary collapse

Class Method Details

.response_status_from_error(error) ⇒ Object

class Themes < R ‘/themes/(.+)’

  MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript',
                '.jpg' => 'image/jpeg'}
  PATH = $CONF.themes_dir || File.expand_path(File.dirname(__FILE__))+'/../themes'

  def get(path)
    headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
    unless path.include? ".." # prevent directory traversal attacks
      headers['X-Sendfile'] = "#{PATH}/#{path}"
      data = File.read(headers['X-Sendfile'])
      headers['Content-Length'] = data.size.to_s # Rack Camping adapter chokes without this
      return data
    else
      status = "403"
      "403 - Invalid path"
    end
  end
end


445
446
447
448
449
450
451
452
453
454
# File 'lib/casserver/controllers.rb', line 445

def response_status_from_error(error)
  case error.code.to_s
  when /^INVALID_/, 'BAD_PGT'
    422
  when 'INTERNAL_ERROR'
    500
  else
    500
  end
end