Google App Engine's db.UserProperty with rpxnow

∥☆過路亽.° 提交于 2019-12-11 17:53:09

问题


We have a Django project which runs on Google App Engine and used db.UserProperty in several models. We don't have an own User model.

My boss would like to use RPXNow (Janrain) for authentication, but after I integrated it, the users.get_current_user() method returned None. It makes sense, because not Google authenticated me. But what should I use for db.UserProperty attributes? Is it possible to use rpxnow and still can have Google's User object as well?

After this I tried to use OpenID authentication (with federated login) in my application, and it works pretty good: I still have users.get_current_user() object. As far as I know, rpxnow using openID as well, which means (for me) that is should be possible to get User objects with rpxnow. But how?

Cheers, psmith


回答1:


You can only get a User object if you're using one of the built-in authentication methods. User objects provide an interface to the Users API, which is handled by the App Engine infrastructure. If you're using your own authentication library, regardless of what protocol it uses, you will have to store user information differently.




回答2:


I haven't tried it yet, but App Engine now supports Federated Login (OpenID) as an authentication mechanism. You can enable it from your dashboard.

Read more here: http://code.google.com/googleapps/domain/sso/openid_reference_implementation.html

Regardless of this, it is very easy -once you have integrated RPXNow- to link it to your application using the Polymodel, as follows:

class InternalUser(polymodel.PolyModel):
  name = db.StringProperty(required=True)
  groups = db.ListProperty(db.Key)

class GoogleUser(InternalUser):
  google_user = db.UserProperty(required=True)

class OpenIDUser(InternalUser):
  unique_identifier = db.StringProperty(required=True)

And then instead of using db.UserProperty you would use db.ReferenceProperty(required=True, reference_class=InternalUser).



来源:https://stackoverflow.com/questions/3699751/google-app-engines-db-userproperty-with-rpxnow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!