Hi there,
I'd like to have a mapping of users to accounts, and then have users directed to a namespace corresponding to their account.
Having looked at the appengine_config.py
from the suggested example, there appear to be a few suggested ways to determine what the namespace ought to be, i.e.
- Server name
- Google Apps Domain
- Cookie
I would like to have namespaces selected based on a lookup in the datastore. i.e.
namespace = user.account.name
For some user
object that is linked to an account
, which account has a name
field. There area few ways I've posited to accomplish this:
- datastore lookup on each request
- memcache lookup on each request (fallback to datastore when memcache expires)
- secure cookie data
The datastore lookup would be two slow. Is there any such reservation with a memcache lookup? e.g. memcache.get('nslookup:%s' % user_id)
, given a user_id
. (I trust the users
object works as expected in appengine_config.py
).
Alternatively, one could use a secure cookie to solve this. I'm not satisfied with the security of the "Secure" flag (i.e. forcing SSL). However, I'm not sure about how best to secure the data in the cookie. I suppose symmetric encryption with signing with PyCrypto using a secret key in GAE along is one way to get started on this path. Although this pattern has been vetted, I'd be grateful for any thoughts on this suggested solution in particular.
Secure cookies don't seem the best route from an idealogical standpoint; I already expect to have the user identity, all I need is a mapping from the user to their account - there is no logical basis for encrypting, sending, storing, receiving, and decrypting that mapping on every request. The memcache options seems best of the three, but I'd be grateful for thoughts and input. The only reason I can think of to use secure cookies would be performance, or alternatively if memcache access were unavailable in the appengine_config.py
.
Thoughts and input and challenges to my assumptions are most welcome.
Thank you for reading.
Brian