Vanilla + Rails = Single sign in goodness
I’ve set up a forum for userstyles.org so my users can discuss Stylish and the site and styles without being to confined to a single thread on mozillaZine. When deciding on a forum, the main thing I was looking for was the ability to integrate it with the current site - a forum account and a main site account would be the same thing, the ability to automatically generate topics, etc. I initially tried looking for a Rails forum to go with my Rails site, thinking this would offer the greatest possibility for integration. I looked at Beast, the 500-line of code forum. I soon discovered the problem of my Rails approach - Beast expected to be its own app rather than part of the existing app. So much for that level of integration.
I eventually stumbled on this post by Jesse Skinner. He described a very easy way of integrating Vanilla (a PHP forum) with a Rails app (or any type of app, for that matter). Since Dreamhost supports PHP and I couldn’t include a Rails forum in my app, I gave it a try, and everything worked great.
Some extra tweaks/info above what Jesse suggested:
- When programmatically creating a user, you need to at least specify name, password, role ID, and the first visit date.
- I wanted a user’s name to be the same on the main site and in the forum. To accomplish this, I had my Rails code update the forum user’s name on update. I also disallowed people from directly changing their name in Vanilla with this setting: $Configuration['ALLOW_NAME_CHANGE'] = ‘0′;
- I wanted a sign in on the forum to mean the same as a sign in on the main site. Same for sign out. I updated the following Vanilla settings to point to my Rails’s login and logout logic: SIGNIN_URL, SIGNOUT_URL, SAFE_REDIRECT
- Since the forum sign in is handled by the Rails app, $Configuration['ALLOW_PASSWORD_CHANGE'] = ‘0′;
- The forum install process requires a database user with the rights to create the tables. Once this was done, I created a new user with CRUD on the forum tables and nothing else.
March 17th, 2007 at 4:57 pm
I’ve been trying to get this to work, but there’s a routing error. mydomain.com/forum and mydomain.com/forum/ end up with a 404, but mydomain.com/forum/index.php works ok.
I’m trying to get a RewriteRule to fix this, but I’m wondering if you had a similar issue, and, if so, how did you fix it?
Thanks!
March 17th, 2007 at 5:18 pm
Doh! I got it. The RewriteRule was below the Rule for finding cached pages. I moved it up and all is well now.
April 2nd, 2007 at 11:19 pm
Jason, any insight as to how you unified the login system’s cookies? I’m assuming that there is slightly different info stored between Vanilla and the authentication system you utilized in your general Rails app?
April 3rd, 2007 at 1:03 pm
Jim, if by “unify” you mean I made Vanilla and the Rails app use the same cookies, I didn’t do that. They each still have a separate set of cookies. As described in #3 and #4 in Jesse Skinner’s blog, the Rails app sets the cookies required by the forum as well as its own when the user logs in or out. Additionally, as I described, I made configuration changes so that the user couldn’t log in to just the forum - it would redirect them to the Rails login page instead.
April 20th, 2007 at 8:28 am
Hey Jason,
I want to have a single sign on with vanilla and my website(developed with php) just wondered what the best way to approach this will be. Thanks.
May 2nd, 2007 at 11:12 am
[...] Vanilla + Rails = Single sign in goodness [...]
September 5th, 2008 at 6:01 am
Thanks for the tips, would have lost a lot of hair over the “role_id” and the first visit date.