django - using an auth token with an event -


an issue having determining how create security token associated page secure page , hold information visitor. i'd prefer hash function instead of encrypt because faster. optimal method can send url like:

/event/1?token=239874dsjakl.jf82374hanfan 

where token have information in related person clicking link , event? use salts or encryption/decryption worthwhile?

you can create table store information associated generated token:

class authtoken(models.model):     token = models.charfield(max_length=255)     user = models.foreignkey(user)     used = models.booleanfield(default=false)     # add additional fields need store information token     # event = models.foreignkey.... 

to generate random cryptographically secure token, use os.urandom(). work:

binascii.hexlify(os.urandom(32)).decode('utf-8') # 64 character string 

then can use token in url. e.g.

/event/1?token=0c5a2774537834e870c2dbab1059eb7358fee7da879e0f14748a35414082ea24 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -