git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
738203c
)
Add an optional 'expires' argument to GetSession() to allow longer expirations
author
Stephen Soltesz
<soltesz@cs.princeton.edu>
Fri, 17 Jun 2011 00:01:49 +0000
(20:01 -0400)
committer
Stephen Soltesz
<soltesz@cs.princeton.edu>
Fri, 17 Jun 2011 00:01:49 +0000
(20:01 -0400)
PLC/Methods/GetSession.py
patch
|
blob
|
history
diff --git
a/PLC/Methods/GetSession.py
b/PLC/Methods/GetSession.py
index
6a8ac4c
..
82dccbf
100644
(file)
--- a/
PLC/Methods/GetSession.py
+++ b/
PLC/Methods/GetSession.py
@@
-11,14
+11,18
@@
class GetSession(Method):
"""
Returns a new session key if a user or node authenticated
successfully, faults otherwise.
"""
Returns a new session key if a user or node authenticated
successfully, faults otherwise.
+
+ Default value for 'expires' is 24 hours. Otherwise, the returned
+ session 'expires' in the given number of seconds.
"""
roles = ['admin', 'pi', 'user', 'tech', 'node']
"""
roles = ['admin', 'pi', 'user', 'tech', 'node']
- accepts = [Auth()]
+ accepts = [Auth(),
+ Parameter(int,"expires", nullok=True)]
returns = Session.fields['session_id']
returns = Session.fields['session_id']
- def call(self, auth):
+ def call(self, auth
, expires=None
):
# Authenticated with a session key, just return it
if auth.has_key('session'):
return auth['session']
# Authenticated with a session key, just return it
if auth.has_key('session'):
return auth['session']
@@
-27,7
+31,10
@@
class GetSession(Method):
if isinstance(self.caller, Person):
# XXX Make this configurable
if isinstance(self.caller, Person):
# XXX Make this configurable
- session['expires'] = int(time.time()) + (24 * 60 * 60)
+ if expires is None:
+ session['expires'] = int(time.time()) + (24 * 60 * 60)
+ else:
+ session['expires'] = int(time.time()) + int(expires)
session.sync(commit = False)
session.sync(commit = False)