Jul 12, 2008

Playing With Grails: OpenID Integration

I'm toying with the idea of turning the Erlang Challenge into a real website. Why not using Grails? I thought the first thing I would need is a user login. Now, I hate logging into websites with a vengeance. Take Facebook for example. Maybe it's an incredible website but because I can't find out without signing up I haven't signed up.

Wow. That was a total aside. Anyway, OpenID seems to be a happy compromise. It's easy to use and it doesn't feel risky. I already have an OpenID via my Blogger account. Great.

So how easy is it to setup a Grails app supporting OpenID?

1. grails create-app challenge
2. cd challenge
3. grails install-plugin openid
4. grails create-controller User
5. Copy and paste the sample login.gsp into grails-app/views/user
6. Edit my UserController:

class UserController {

def login = { }

def loggedin = { redirect(uri:'/') }

}
7. grails run-app
8. Navigate to http://localhost:8080/user/login and it works

Granted, this isn't doing anything interesting in the loggedin action, there are no filters to enforce a login, and I'm not linking a login to a User object.

It is nice to be able to do something quickly though isn't it?

Footnote: this is the first image that I've drawn for my blog using my (now not so new) Bamboo graphics tablet.

1 comments:

tobileitner said...

hi can i ask you a question about openID and Grails? if you read this please send me an email to : tobileitner(at)online.de