Github example
Thread discussing the example
Written by Tim Williams
========
The lift-openid module can be used to add OpenID support to your Lift app.
For SBT in libraryDependencies:
"net.liftweb" %% "lift-openid" % liftVersion % "compile->default"
For Maven in pom.xml \depencies:
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-openid_2.9.1</artifactId>
<version>2.4</version>
</dependency>
Then, for example:
import _root_.org.openid4java.discovery.DiscoveryInformation
import _root_.org.openid4java.message.AuthRequest
object MyVendor extends SimpleOpenIDVendor {
def ext(di: DiscoveryInformation, authReq: AuthRequest): Unit = {
import WellKnownAttributes._
WellKnownEndpoints.findEndpoint(di) map {ep =>
ep.makeAttributeExtension(List(Email, FullName, FirstName, LastName)) foreach {ex =>
authReq.addExtension(ex)
}
}
}
override def createAConsumer = new OpenIDConsumer[UserType] {
beforeAuth = Full(ext _)
}
}
object User extends User with MetaOpenIDProtoUser[User] with LongKeyedMetaMapper[User] {
def openIDVendor = MyVendor
override def screenWrap = Full(<lift:surround with="default" at="content"><lift:bind /></lift:surround>)
override def dbTableName = "users"
override def homePage = if (loggedIn_?) "/dashboard" else "/"
}
class User extends LongKeyedMapper[User] with OpenIDProtoUser[User] {
def getSingleton = User
}
And then in Boot.scala:
LiftRules.dispatch.append(model.MyVendor.dispatchPF)
LiftRules.snippets.append(model.MyVendor.snippetPF)