##// END OF EJS Templates
api: expose more details of auth tokens in get_user api call.
marcink -
r1522:82f2feee default
parent child Browse files
Show More
@@ -63,6 +63,7 b' def get_user(request, apiuser, userid=Op'
63 63 "active": true,
64 64 "admin": false,
65 65 "api_keys": [ list of keys ],
66 "auth_tokens": [ list of tokens with details ],
66 67 "email": "user@example.com",
67 68 "emails": [
68 69 "user@example.com"
@@ -915,6 +915,7 b' class User(Base, BaseModel):'
915 915
916 916 extras = {
917 917 'api_keys': [api_key_replacement],
918 'auth_tokens': [api_key_replacement],
918 919 'active': user.active,
919 920 'admin': user.admin,
920 921 'extern_type': user.extern_type,
@@ -927,6 +928,7 b' class User(Base, BaseModel):'
927 928
928 929 if include_secrets:
929 930 data['api_keys'] = user.auth_tokens
931 data['auth_tokens'] = user.extra_auth_tokens
930 932 return data
931 933
932 934 def __json__(self):
@@ -985,6 +987,21 b' class UserApiKeys(Base, BaseModel):'
985 987 def __unicode__(self):
986 988 return u"<%s('%s')>" % (self.__class__.__name__, self.role)
987 989
990 def __json__(self):
991 data = {
992 'auth_token': self.api_key,
993 'role': self.role,
994 'scope': self.scope_humanized,
995 'expired': self.expired
996 }
997 return data
998
999 @property
1000 def expired(self):
1001 if self.expires == -1:
1002 return False
1003 return time.time() > self.expires
1004
988 1005 @classmethod
989 1006 def _get_role_name(cls, role):
990 1007 return {
@@ -996,12 +1013,6 b' class UserApiKeys(Base, BaseModel):'
996 1013 }.get(role, role)
997 1014
998 1015 @property
999 def expired(self):
1000 if self.expires == -1:
1001 return False
1002 return time.time() > self.expires
1003
1004 @property
1005 1016 def role_humanized(self):
1006 1017 return self._get_role_name(self.role)
1007 1018
General Comments 0
You need to be logged in to leave comments. Login now