Extracting CAS configuration into YAML, like database.yml

If you’ve done any enterprise work with Rails, and your shop is using CAS for authentication, chances are you’ve seen rubycas-client. Chances are you’ve also loved how easy it was to get working. There’s usually only one hitch — you’ve got to change the config based on which environment you’re deploying into.

Here’s the standard advice you get from the RDoc:

# in your config/environment.rb
CASClient::Frameworks::Rails::Filter.configure(
  :cas_base_url => https://cas.example.foo/,
  :proxy_retrieval_url => https://cas-proxy-callback.example.foo/cas_proxy_callback/retrieve_pgt,
  :proxy_callback_url => https://cas-proxy-callback.example.foo/cas_proxy_callback/receive_pgt,
  :logger => cas_logger
)

But with a tiny change, you can give your CAS setup all the flexibility and auto-magical environmental savvy of database.yml. Goodbye last minute edits for a production deployment. Check this out:

# in your config/environment.rb
cas_options = YAML::load_file(RAILS_ROOT+/config/cas.yml)
CASClient::Frameworks::Rails::Filter.configure(cas_options[RAILS_ENV])

Now make a simple YAML file, cas.yml:

# config/cas.yml
development:
    :cas_base_url: https://cas.qaexample.tld/cas/
    :validate_url: https://cas.qaexample.tld/cas/validate
    :logout_url: https://cas.qaexample.tld/cas/logout

test:
    :cas_base_url: https://cas.qaexample.tld/cas/
    :validate_url: https://cas.qaexample.tld/cas/validate
    :logout_url: https://cas.qaexample.tld/cas/logout

production:
    :cas_base_url: https://cas.example.tld/cas/
    :validate_url: https://cas.example.tld/cas/validate
    :logout_url: https://cas.example.tld/cas/logout

It’s worth noting that the colons in front of the YAML keys indicate that those keys are Ruby symbols, not strings. All the rubycas-client docs use symbols in their examples, so I’d follow their lead if I were you.

Got an opinion about using CAS with Rails? Leave a comment and let us hear it!

HOWTO port install md5sum on your Mac

I’ve been using Linux for a long time. While it lost the battle for my desktop, it still reigns supreme in my server world. I have this very occasional habit of wanting to check if two files are really, honestly, undoubtedly the same.

I had that need again today.

I’ve always used md5sum on Linux. sudo port search md5sum was a bust. I Googled around. I figured I’d just have to find the package that contains md5sum and sudo port install [package]. No dice. Nothing promising for miles around, or at least through page 5 of the Google results.

Eventually I landed on Wikipedia’s md5sum page. Then a flood of vague memories hit me. Macs have a similar program, but it’s named md5 and its output formatting is slightly different (but the calculated hash is the same). It had been ages since I had discovered this, and I had totally forgotten.

So, instead of sudo port install md5sum, I’ve edited my ~/.bash_aliases file to contain this:

alias md5sum=man md5

Maybe there really is a fabled md5sum for Mac, but this is good enough for me. This will remind the more frozen part of my brain that I really want to type md5 [filename] instead. And then I won’t go a-Googling for it any more. And perhaps, neither will you.

P.S. the md5 man page on my Mac shows it to be part of openssl, just in case you wondered.

How to Configure Entourage Rules to Send All Appointments to a Folder

I’ve wanted to do this for months. I’ve searched Google a number of times, and never found a suitable solution for sending ALL my appointment requests in Entourage to a specific folder. I finally hit on it today. The key? Use Specific Header 'Content-class' Contains 'calendarmessage'.

Configuration screen for a rule in Entourage that will send all appointments to a specific folder.