Felipe Koch's Endeavours
Getting RubyCAS-Server running on Heroku

Since I’m building this system that will have many apps that will require a central authentication server (CAS), and since I’m most experienced with Ruby, I chose the great RubyCAS-Server to handle the heavy lifting.

My host of choice for Ruby apps is Heroku. They take the trouble of maintaining web servers and installing software and configuring applications away from you. And they do it while providing a very simple deployment strategy (git push heroku). All that while not charging that much more than what you would pay for a bare bones instance on Amazon AWS.

All that goodness comes with a price: in order for your app to be scalable in a cloud environment, you don’t have access to a file system, you don’t have access to a shell, so you don’t have root access which is what RubyCAS-Server requires by default.

If you try to run it, it will complain:

Loading configuration for “rubycas-server” from “/etc/rubycas-server/config.yml”…

RUBYCAS-SERVER SERVER HAS NOT YET BEEN CONFIGURED!!!

Attempting to copy sample configuration from ‘/disk1/home/slugs/194894_4dff271_c804/mnt/config.example.yml’ to ‘/etc/rubycas-server/config.yml’…

It appears that you do not have permissions to create the ‘/etc/rubycas-server/config.yml’ file. Try running this command using sudo (as root).

So, in order to make it run on Heroku you need to first create your copy of the sample config file:

$ cp config.example.yml rubycas-server.yml

Then edit the file lib/casserver/conf.rb. The initial declaration of the local var “conf_defaults” becomes:

  conf_defaults = {
    :maximum_unused_login_ticket_lifetime => 5.minutes,
    :maximum_unused_service_ticket_lifetime => 5.minutes,
    :maximum_session_lifetime => 1.month,
    :log => {:file => ‘casserver.log’, :level => ‘DEBUG’},
    :uri_path => “/”,
    :conf_file => ‘rubycas-server.yml’
  }

And the first call to “$CONF.load_from_file” becomes:

$CONF.load_from_file($APP_NAME, $APP_ROOT, conf_defaults[:conf_file])

This should be it! Now when you deploy to Heroku it will read the correct configuration file automatically.

I still wasn’t able to make it connect to the Heroku provided PostgreSQL database through ENV[‘DATABASE_URL’], but when I do I’ll post it here.