Check out how easy the integration of OpenID into Grails is:
1. Create a new grails application: grails create-app openID
2. Change into directory: cd openID
3. Install Plugin: grails install-plugin openid
4. Create a new controller: grails create-controller User
5. Create logon.gsp at grails-app/views/user
6. Add the following lines of code
<openid:css />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<title>Login</title>
<openid:css />
</head>
<body>
<h1>Login</h1>
<openid:hasLoginError>
<div class="errors">
<ul>
<li><openid:renderLoginError /></li>
</ul>
</div>
</openid:hasLoginError>
<openid:form success="[action:'loggedin']">
<openid:input size="30" value="http://" /> (e.g. http://username.myopenid.com)
<br/>
<g:submitButton name="login" value="Login" />
</openid:form>
</body>
</html>
7. Edit UserController and add
class UserController { def login = { } def loggedin = { redirect(uri:'/') } }
8. Call grails run-app
9. Open your web browser at http://localhost:8080/openID/User/login.gsp
10. Use your OpenID account to log on like Yahoo OpenID.
Check out http://docs.codehaus.org/display/GRAILS/OpenID+Plugin for further information about the Grails openID plugin
Leave a Reply