I am trying to get both the basic auth and open id working together on
GAE.  I have managed to get it working on the web2py.py server, but I
still have some minor issues with GAE.  It has taken me about 2 days
to get to this point, and I am SOO close to having a perfectly working
setup.

My configuration is as follows:
== db.py ==
from gluon.contrib.login_methods.openid_auth import OpenIDAuth
openid_login_form = OpenIDAuth(auth)

== controller ==
def user():
    if 'janrain_nonce' in request.vars: # if openid form has been
submitted
      auth.settings.login_form = openid_login_form
      return dict(form=auth())

    if 'login' in request.args: # if we are on the login page
      form = DIV(
              DIV(auth()),
              DIV(openid_login_form.login_form()))
    else:
      form = auth()

    if 'profile' in request.args: # if we are on the profile page
      form = DIV(form, openid_login_form.list_user_openids()) # append
the openid's for this user to the login form (also appends the 'add
openid' form)

    return dict(form=form)

This appends the OpenID login form to the 'login' page.  It also
appends the 'list openids' to the profile page.  If the openid form is
submitted it will be caught by the first if statement in the
controller and get handled by auth.

NOTE:
On line 244 of gluon/contrib/login_methods/openid_auth.py there is bug
that I had to fix in order for this to work.
- self.db.alt_logins.insert(username=oid, user=user)
+ self.db.alt_logins.insert(username=oid, user=user.id) #changed user
to user.id to get rid of db error...

With this configuration I have been able to successfully (on default
server):
- login using the basic auth form.
- view my profile and see the openid list (with form).
- in the profile, add an open id to the list.
- in the profile, remove an open id from the list.
- login using the associated openid for a specific user.
(everything works as expected)

On GAE I have the following:
- login using the basic auth form. (works)
- view my profile and see the openid list (with form). (works)
- in the profile, add an open id to the list. (see note below)
- in the profile, remove an open id from the list. (works)
- login using the associated openid for a specific user. (works)

The main problem I have now is that when I associate an OpenID with an
account (aka - on the profile page, enter an openid into the form and
then click 'Add'), I have the following symptoms...

I am taken to a page that has the following on it:
URL:
http://localhost:8080/init/default/user/login?_next=/init/default/user/profile&janrain_nonce=2011-03-29T17%3A16%3A35ZfAY3Z0&openid.ns=http%3A%2F%2Fspecs.ope
... etc ... ntity=https%3A%2F%2Fprofiles.google.com
%2Fwilliamstevens&openid.claimed_id=https%3A%2F%2Fprofiles.google.com
%2Fwilliamstevens

Page Content:
[DB] profiles.google.com/williamstevens authenticated
Status: 303 SEE OTHER
Set-Cookie:  session_id_cloudops="292:7dfe3917- ...etc... -
a0077e6f94f6"; Path=/
Content-Type: text/html; charset=UTF-8
Location: /init/default/user/profile

You are being redirected <a href="/init/default/user/profile">here</a>


I need this redirect to actually happen and not just be shown on the
page to the user.  If I can make that redirect happen, I have finally
made this work.

Please let me know if you have any ideas.

Thanks,

Will

Reply via email to