目次

Version 5, last updated by olger at Nov 23 19:28 UTC

lift-openid モジュール (net.liftweb.openidScalaDocs) を使うと、作成する Lift アプリケーションに OpenID サポートを追加することができます。

次に例を示します。

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 
} 

Boot.scala には、次のように記述します。

LiftRules.dispatch.append(model.MyVendor.dispatchPF) 
LiftRules.snippets.append(model.MyVendor.snippetPF)