New OpenID lib

77 views
Skip to first unread message

Guillaume Bort

unread,
Aug 12, 2009, 2:04:32 PM8/12/09
to play-fr...@googlegroups.com
Hi guys,

I just committed a new version of the play.libs.OpenID. The old one
was dependent of OpenID4Java and it was a mess (pretty bad lib).

I tested it with a lot of OP including Myopenid, claimid, yahoo,
google, livejournal, flickr, technorati, launchpad. But if you have
the time to test
others OP I would love it.

The API has changed a little to make it easier to support both SReg
and Attributes exchange.

Here an updated version of the manual sample:

public static void authenticate(String claimedID) {
if(OpenID.isAuthenticationResponse()) {
// Retrieve the verified id
UserInfo user = OpenID.getVerifiedID();
if(user == null) {
flash.put("error", "Oops. Authentication has failed");
login();
} else {
session.put("user.id", user.id);
session.put("user.email", user.extensions.get("email"));
index();
}
} else {
// Verify the id
if(!OpenID.id(claimedID).required("email").verify()) {
flash.put("error", "Oops. Cannot discover this openid");
login();
}
}
}

You can even use it without claimed ID. Here how to authenticate your
users using the Google Federated login (works for yahoo too):

public static void authenticate() {
if(OpenID.isAuthenticationResponse()) {
// Retrieve the verified id
UserInfo user = OpenID.getVerifiedID();
if(user == null) {
flash.put("error", "Oops. Authentication has failed");
index();
} else {
session.put("user.id", user.id);
session.put("user.email", user.extensions.get("email"));
index();
}
} else {
// Verify the id
if(!OpenID.id("https://www.google.com/accounts/o8/id").required("email",
"http://axschema.org/contact/email").verify()) {
flash.put("error", "Oops. Cannot contact google");
index();
}
}
}

Alberto Gimeno

unread,
Aug 12, 2009, 5:02:29 PM8/12/09
to play-fr...@googlegroups.com
Hi!

Have you implemented a wrapper of a library or have you implemented
all the OpenID stuff by yourself?

Great worrk!
--
Alberto Gimeno Brieba
email and gtalk: gime...@gmail.com
blog: http://gimenete.net
mobile phone: +34 625 24 64 81

Guillaume Bort

unread,
Aug 12, 2009, 5:24:38 PM8/12/09
to play-fr...@googlegroups.com
I rewritten it from scratch because I haven't found any simple lib
that doesn't depend of the servlet API.
Then it is simpler for me to correct bug related to OP implementations.

Ignacio Andreu

unread,
Dec 3, 2009, 4:03:52 AM12/3/09
to play-fr...@googlegroups.com
Hi Guillaume,

First of all, you did a great work with the implementation, it's pretty easy, congrats!!

I've been testing play 1.0 and OpenID and it doesn't work with yahoo. Can you test it please? FYI we have been using dyuproject 1.1.5 and suddenly it doesn't work with Yahoo, so I'm pretty sure Yahoo changed its OpenID system.

Also, would be great if you can add more info about how to use OpenID in the documentation. There is no examples about how configure play to ask sreg params.

Thanks,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com
To unsubscribe from this group, send email to play-framewor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en
-~----------~----~----~----~------~----~------~--~---




--
Web Page: http://www.masterbranch.com/

Guillaume Bort

unread,
Dec 3, 2009, 4:49:45 AM12/3/09
to play-fr...@googlegroups.com
Ok I will check that.
> --
>
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

Guillaume Bort

unread,
Dec 3, 2009, 1:51:39 PM12/3/09
to play-fr...@googlegroups.com
Ok, so. I just tested this controller:

package controllers;

import play.mvc.*;
import play.libs.*;
import play.libs.OpenID.*;

public class Application extends Controller {

public static void index() {
render();
}

public static void authenticate() {
if(OpenID.isAuthenticationResponse()) {
// Retrieve the verified id
UserInfo user = OpenID.getVerifiedID();
if(user == null) {
flash.put("error", "Oops. Authentication has failed");
index();
} else {
session.put("user.id", user.id);
session.put("user.email", user.extensions.get("email"));
index();
}
} else {
// Verify the id
if(!OpenID.id("https://me.yahoo.com/guillaume_bort").required("email",
"http://axschema.org/contact/email").verify()) {
flash.put("error", "Oops. Cannot contact yahoo");
index();
}
}
}

}

As you see I use my yahoo OpenID and ask for email attribute.

And it works for me.

Ignacio Andreu

unread,
Dec 3, 2009, 3:24:49 PM12/3/09
to play-fr...@googlegroups.com
Usually when you use Yahoo as OpenID provider you don't ask for the username, you just have yahoo.com as URL. Check some OpenID UI selectors like OpenID selector http://openid-selector.googlecode.com/svn/trunk/demo.html or id selector https://www.idselector.com/user/login

Thanks,

Guillaume Bort

unread,
Dec 3, 2009, 3:55:13 PM12/3/09
to play-fr...@googlegroups.com
Ah yes ok. I see what you mean. I'll try again.

Ignacio Andreu

unread,
Dec 29, 2009, 7:59:55 AM12/29/09
to play-fr...@googlegroups.com
Hi,

Finally I did a workaround to use yahoo as OpenID provider, instead of http://yahoo.com I use http://me.yahoo.com and it works. I've been testing it with other OpenID providers, I found a problem with wordpress, I don't know why but play don't event do the redirect to wordpress, can you please take a look? 

Thanks,

Guillaume Bort

unread,
Dec 29, 2009, 8:07:48 AM12/29/09
to play-fr...@googlegroups.com
Hi Ignacio,

I'm sorry but it seems that my previous response was lost ...

It was:

> Ok so,
>
> First here to solution to fix it:
>
> Use this openid endpoint,
> http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds instead of
> http://yahoo.com
>
> ---
>
> I'm not sure why, but previously when you fetched http://yahoo.com,
> you could find this HTTP header:
>
> X-XRDS-Location: http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds
>
> And now this header is gone ... !
>
> I don't know why. Perhaps there is another to discover it but I've
> read all the OpenID spec and don't found anything about it.

I'll check for wordpress too

Ignacio Andreu

unread,
Dec 29, 2009, 8:24:15 AM12/29/09
to play-fr...@googlegroups.com
Hey! Thanks, I didn't receive the email. Anyway, as I told you before you can use https://me.yahoo.com as the discovery url http://developer.yahoo.net/forum/index.php?showtopic=3379

Regards,

Guillaume Bort

unread,
Dec 29, 2009, 8:34:56 AM12/29/09
to play-fr...@googlegroups.com
Yes. If you look at the HTTP response header coming from me.yahoo.com,
the missing XRDS header is here!

http://hurl.it/hurls/7d4cecd0abe5d68919aa12b51cdfa96b5fa8b7e4/94943c9fd9dcf438e350c8b5b20a657bc7837c24

Vijay Kiran

unread,
Dec 29, 2009, 11:02:32 AM12/29/09
to play-fr...@googlegroups.com
Hello All,

I want to create a plugin similar to DB plugin that will enable accessing the data from a JCR repository. I tried to add my own module similar to the siena module, but the plugin's onApplicationStart is not being invoked.

Is there any documentation on how can I create a plugin ?

TIA for your help,
Vijay Kiran.

Guillaume Bort

unread,
Dec 29, 2009, 11:05:37 AM12/29/09
to play-fr...@googlegroups.com
Hi,

Just check that you have correctly defined the play.plugins file and
that it is correctly packaged in the jar.

Vijay Kiran

unread,
Dec 29, 2009, 11:48:48 AM12/29/09
to play-fr...@googlegroups.com
Hi Guillaume,

Thanks for the response.

I checked the jar file and the contents of the JAR seem fine:

hal36:lib vijaykiran$ jar tvf play-jcr.jar
0 Tue Dec 29 16:44:40 CET 2009 META-INF/
142 Tue Dec 29 16:44:38 CET 2009 META-INF/MANIFEST.MF
0 Tue Dec 29 16:44:40 CET 2009 play/
0 Tue Dec 29 16:44:40 CET 2009 play/jcr/
22 Tue Dec 29 16:44:40 CET 2009 play.plugins
483 Tue Dec 29 16:44:40 CET 2009 play/jcr/JcrPlugin.class


And here's the JcrPlugin.java

public class JcrPlugin extends PlayPlugin {

@Override
public void onApplicationStart() {
Logger.info("JCR Plugin initing");
}
}


TIA,
Vijay

Mike Grove

unread,
Dec 29, 2009, 11:52:17 AM12/29/09
to play-fr...@googlegroups.com
I think the play.plugins file needs to be in the conf directory, at least, that's where I have mine and it works very nicely.

Guillaume Bort

unread,
Dec 29, 2009, 12:05:03 PM12/29/09
to play-fr...@googlegroups.com
In fact it just need to be somewhere at the root of the classpath. So
conf is a good choice for in-application plugins, yes.

Perhaps you can enable TRACE as log level in your application. It
should tell you more about the plugin descriptors found.

Vijay Kiran

unread,
Dec 29, 2009, 12:21:11 PM12/29/09
to play-fr...@googlegroups.com

When I start the application I see module jcr in the log:
18:09:14,591 INFO ~ Module jcr is available (/Users/vijaykiran/Work/sources/1.1/modules/jcr)


But the plugin doesn't seem to be loading, Did I miss something ?

This is what I did so far:

- Created a module/jcr in my playframework source tree (by copying modules/siena)
- Updated the build.xml in modules/jcr and the root build.xml to include the new module.
- Compiled the playframework.
- I can see the module jar and the contents (as in my previous email)
- Created a sample application and added the module.jcr=${play.path}/modules/jcr to my sample application's application.conf

BTW, I'm working with Play 1.1 branch source code.

Thanks,
Vijay

Guillaume Bort

unread,
Dec 29, 2009, 12:32:02 PM12/29/09
to play-fr...@googlegroups.com
Do you have modified the content of the play.plugins file as well ?

It should be something like:

10:play.jcr.JcrPlugin

>>> fram...@googlegroups.com.

Vijay Kiran

unread,
Dec 29, 2009, 12:42:25 PM12/29/09
to play-fr...@googlegroups.com
Yes, I did.
But I used 0 as the index.

On Dec 29, 2009, at 6:32 PM, Guillaume Bort <guillau...@gmail.com>
wrote:

> Do you have modified the content of the play.plugins file as well ?

Guillaume Bort

unread,
Dec 29, 2009, 1:12:34 PM12/29/09
to play-fr...@googlegroups.com
So it should work (assuming that play-jcr.jar is in the lib folder).

Also in DEV mode the application starts at the first request (and not
at server start)

If it still doesn't work please send me the jar.

Vijay Kiran

unread,
Dec 29, 2009, 1:14:23 PM12/29/09
to play-fr...@googlegroups.com
I just cleared my test project and recreated it.

The new plugin seems to loading and working fine, I'm not sure what went wrong before though.

Thanks for your help,
./Vijay


To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

Vijay Kiran

unread,
Dec 29, 2009, 1:54:28 PM12/29/09
to play-fr...@googlegroups.com
Ok I figured out why my plugin wasn't working. 

When I run the test project in Netbeans the plugins under modules are not loaded. If I run the same application using play command I can see the plugin in action. 

I think the classpath for the nb-run-application needs to be fixed so that it picks up modules/*/lib/*.jar
 
Regards,
Vijay


Reply all
Reply to author
Forward
0 new messages