Sample Rails App Branch: With SSL

Courtenay : April 20th, 2007

If you’ve ever wondered exactly how to get SSL going with your rails app, look no further. I’ve made a branch of the sample app that contains all the necessary SSL code.

View the code: http://sample.caboo.se/empty_with_ssl/

Subversion: svn://caboo.se/plugins/court3nay/empty_apps/ssl

I’ve included a self-signed certificate .pem file for localhost, and a sample lighttpd config file. So you can start lighttpd and it’ll proxy through to your app running on port 3000, and handle SSL requests as well.

The user controller on edit/update/create, and session controller (all actions) have ssl requirements, and will automatically redirect as required.

I’d love some more sample configs and install instructions for other systems; also, the app needs testing and running on Windows.

13 Responses to “Sample Rails App Branch: With SSL”

  1. Matthijs Langenberg Says:

    I’m telling you, this application is getting bloated by the minute.

  2. aphelion Says:

    Good stuff, and even contained in a seperate branch. Thankyou kindly.

  3. Antonio Says:

    Matthijs Langenberg:

    Do I really care about what you think? Give it a rest. Sample app is a good thing and I love it! So please do your ranting somewhere else :-)

  4. Donovan Dillon Says:

    Thanks Courtenay. This resource is a godsend to us Rails newbies. Please keep them coming.

  5. Morten Says:

    A sample app generator would be nice. Checkboxes for plugins/settings, and piced together on the fly. And some time in the future, managable by a piston-like thingy.

  6. Mike Says:

    Very sweet. Just one thing, a part of the test/ tree appears to be missing from svn.

  7. Court3nay Says:

    nope. it’s using rspec.

  8. Mike Says:

    Doh. Switching to rspec now. Thanks :)

  9. Ben Says:

    Looks like the rspec version you are using is old. It throws errors when the rspec gem version and rails plugin don’t match. Do you intend on updating this part of the app?

  10. Valery Says:

    can’t get emptywithssl running with posgresql. i always get:

    FATAL: Ident authentication failed for user “myusernamehere”

    however all other rubyonrails apps works just fine with same my installation/efforts.

    BTW, the phppgadmin can log in and do things with my database using the same credentials for user “myusernamehere”

    this user “myusernamehere” is actually an ubuntu user and i could assume some special interferences here reflected in emptywithssl

    any idea what’s going on?

    thanks,

    Valery.

  11. Valery Says:

    OK, i see that the “FATAL: Ident authentication failed for user” issue is something that i get with any rubyonrails applications when i try to switch from WEBrick to lighttpd. and bad-bad-bad google says n0th1ng

  12. Victor Cosby Says:

    Lovely.

    One slight tweak, however. To create new users you’ll want to add :new to ssl_required in the UsersController.

    ssl_required :edit, :update, :create, :new

  13. seb Says:

    A little thing in to_xml of user, as it’s not the correct function definition, it does not works with an array of users, it should be

    def to_xml(options = {}) super( options.merge(:only => [ :login, :timezone, :lastlogin_at ] )) end

Sorry, comments are closed for this article.