Are there any OpenID tutorials?

33 views
Skip to first unread message

Peter Robinett

unread,
Apr 7, 2010, 6:35:13 PM4/7/10
to Lift
Hi all,

I'd like to add OpenID logins to my Lift app and would love a tutorial
about how to do so. I assume I mix OpenIDProtoUser into my User model,
but I don't know what to do beyond that. Can anyone point me in the
right direction?

Thanks!

Peter

PS This would make a great Wiki article.

Dick Hirsch

unread,
Apr 8, 2010, 2:10:59 AM4/8/10
to Lift
We use OpenID in ESME although we don't use any "*ProtoUser"

Maybe, you can get some pointers there.

Take a look here:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala?view=markup

Dick

Co-Project Lead / Apache ESME
"The only Apache project written in Scala and based on Lift"
http://cwiki.apache.org/confluence/display/ESME/Index

Jeppe Nejsum Madsen

unread,
Apr 8, 2010, 3:46:08 AM4/8/10
to lif...@googlegroups.com
Peter Robinett <pe...@bubblefoundry.com> writes:

Indeed. I have a blog post waiting for this (I know, lots of promises :-)

But here's a sample that should work:

object MyVendor extends SimpleOpenIDVendor {
def ext(di:DiscoveryInformation, authReq: AuthRequest): Unit = {
import WellKnownAttributes._
WellKnownEndpoints.findEndpoint(di) map {ep => ep.makeAttrExtension(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 FancyKeyedMetaMapper[Long,User] with FancyCRUDify[Long,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 OpenIDProtoUser[User] {
def getSingleton = User
}


And then in Boot

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


/Jeppe

Peter Robinett

unread,
Apr 8, 2010, 1:06:12 PM4/8/10
to Lift
Thanks. I haven't tested it myself yet, but I went ahead and threw up
a wiki page anyway:
https://www.assembla.com/wiki/show/liftweb/OpenID

Peter

Peter Robinett

unread,
Apr 12, 2010, 10:51:48 PM4/12/10
to Lift
Jeppe, you wouldn't happened to have tried to use it with SBT, would
you?

I'm using the following lines in my SBT project declaration:
val lift = "net.liftweb" % "lift-mapper" % "2.0-SNAPSHOT" % "compile"
val liftOpenID = "net.liftweb" % "lift-openid" % "2.0-SNAPSHOT" %
"compile"

Unfortunately, when I try to import net.liftweb.openid._, I'm told it
doesn't exist. Anyone able to hazard a guess?

Thanks,
Peter

On Apr 8, 12:46 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:

> Peter Robinett <pe...@bubblefoundry.com> writes:
> > Hi all,
>

> > I'd like to addOpenIDlogins to my Lift app and would love a tutorial

Timothy Perrett

unread,
Apr 13, 2010, 3:48:18 AM4/13/10
to lif...@googlegroups.com
Sounds like you haven't called update from the sbt console

Sent from my iPhone

On 13 Apr 2010, at 03:51, Peter Robinett <pe...@bubblefoundry.com>
wrote:

> --
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
> .
>
>

Peter Robinett

unread,
Apr 13, 2010, 4:25:39 AM4/13/10
to Lift
Actually it turns out I hadn't called reload before calling update.
Sorry to pollute the list!

David Pollak

unread,
Apr 13, 2010, 12:06:03 PM4/13/10
to lif...@googlegroups.com
On Tue, Apr 13, 2010 at 1:25 AM, Peter Robinett <pe...@bubblefoundry.com> wrote:
Actually it turns out I hadn't called reload before calling update.
Sorry to pollute the list!

No list pollution from my perspective.  There'll be 100 people that hit this same issue as sbt becomes a (rightfully) more popular way to do Lift coding.  Getting used to the frequently hit stumbling blocks will help us help people.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Peter Robinett

unread,
Apr 21, 2010, 6:16:05 PM4/21/10
to Lift
Hey Jeppe, I'm only trying to use your example now and am having some
problems. While I figured out where to import DiscoveryInformation and
AuthRequest and that ep.makeAttrExtension should be
ep.makeAttributeExtension (I created ticket #488 for myself to update
the ScalaDocs), I now get an exception when I try to login after
entering my OpenID URL:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

Is this a missing dependency in lift-openid or have I missed a logging
setup step in my Boot.scala?

Thanks,
Peter

On Apr 8, 12:46 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:

Jeppe Nejsum Madsen

unread,
Apr 22, 2010, 2:35:00 AM4/22/10
to lif...@googlegroups.com
Peter Robinett <pe...@bubblefoundry.com> writes:

> Hey Jeppe, I'm only trying to use your example now and am having some
> problems. While I figured out where to import DiscoveryInformation and
> AuthRequest and that ep.makeAttrExtension should be
> ep.makeAttributeExtension (I created ticket #488 for myself to update
> the ScalaDocs), I now get an exception when I try to login after
> entering my OpenID URL:
> java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
>
> Is this a missing dependency in lift-openid or have I missed a logging
> setup step in my Boot.scala?

This is because "something" depends on commons-logging (which should be
avoided like the plague if you ask me :-). SLF4J has a wrapper that you
can add which tunnels requests to CL through to your chosen SLF4j
logging system. It's called jcl-over-slf4j.jar.

I thought I'd made this dependency exclusion in the poms, but either I
didn't or it doesn't work. If you create a ticket for this I'll look
into it. In the meantime you should be able to continue by adding
jcl-over-slf4j as dependency....

Peter Robinett

unread,
Apr 22, 2010, 1:33:44 PM4/22/10
to Lift
Reply all
Reply to author
Forward
0 new messages