summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorequinox <equinox@diac24.net>2011-04-01 06:27:25 +0200
committerequinox <equinox@diac24.net>2011-04-01 06:27:25 +0200
commit18f1e7de1820a63d5f8f49b52205b70a2107c2ea (patch)
tree2f09b9fe6d2ff344b53a10b10626630fd6c0cd61
parentf323816b73661fa8cb2a1accb4d05ac5b5945fe4 (diff)
add site identifier to ticket
-rw-r--r--ticket.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ticket.py b/ticket.py
index e7697e9..5b9ac2e 100644
--- a/ticket.py
+++ b/ticket.py
@@ -2,23 +2,23 @@ import crypto, socket, time
keyfile = 'subdap-%s.key' % (socket.gethostname())
pubfile = 'subdap-%s.pem' % (socket.gethostname())
-keys = ['user', 'ts', 'sig']
+keys = ['site', 'user', 'ts', 'sig']
-def tgt_create(user):
+def tgt_create(site, user):
ts = int(time.time())
- data = '%d:%s' % (ts, user)
+ data = '%s:%d:%s' % (site, ts, user)
sig = crypto.sign(keyfile, data)
- return {'user': user, 'ts': ts, 'sig': sig}
+ return {'site': site, 'user': user, 'ts': ts, 'sig': sig}
-def tgt_verify(user, ts, sig, maxage = None):
- data = '%d:%s' % (int(ts), user)
+def tgt_verify(site, user, ts, sig, maxage = None):
+ data = '%s:%d:%s' % (site, int(ts), user)
status = crypto.verify(pubfile, data, sig)
if maxage != None:
status &= ts > time.time() - maxage
return status
if __name__ == '__main__':
- sig = tgt_create('test')
+ sig = tgt_create('site', 'test')
print sig
assert not tgt_verify(maxage = -9999, **sig)
assert tgt_verify(maxage = 9999, **sig)