mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 06:22:59 +00:00
add token.api_id
id key used in rest api
This commit is contained in:
@@ -108,13 +108,11 @@ class APIHandler(BaseHandler):
|
|||||||
extra = {
|
extra = {
|
||||||
'note': token.note,
|
'note': token.note,
|
||||||
}
|
}
|
||||||
id = 'a%i' % token.id
|
|
||||||
elif isinstance(token, orm.OAuthAccessToken):
|
elif isinstance(token, orm.OAuthAccessToken):
|
||||||
kind = 'oauth'
|
kind = 'oauth'
|
||||||
extra = {
|
extra = {
|
||||||
'oauth_client': token.client.description or token.client.client_id,
|
'oauth_client': token.client.description or token.client.client_id,
|
||||||
}
|
}
|
||||||
id = 'o%i' % token.id
|
|
||||||
else:
|
else:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"token must be an APIToken or OAuthAccessToken, not %s"
|
"token must be an APIToken or OAuthAccessToken, not %s"
|
||||||
@@ -130,7 +128,7 @@ class APIHandler(BaseHandler):
|
|||||||
|
|
||||||
model = {
|
model = {
|
||||||
owner_key: owner,
|
owner_key: owner,
|
||||||
'id': id,
|
'id': token.api_id,
|
||||||
'kind': kind,
|
'kind': kind,
|
||||||
'created': isoformat(token.created),
|
'created': isoformat(token.created),
|
||||||
'last_activity': isoformat(token.last_activity),
|
'last_activity': isoformat(token.last_activity),
|
||||||
|
@@ -342,6 +342,10 @@ class APIToken(Hashed, Base):
|
|||||||
hashed = Column(Unicode(255), unique=True)
|
hashed = Column(Unicode(255), unique=True)
|
||||||
prefix = Column(Unicode(16), index=True)
|
prefix = Column(Unicode(16), index=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def api_id(self):
|
||||||
|
return 'a%i' % self.id
|
||||||
|
|
||||||
# token metadata for bookkeeping
|
# token metadata for bookkeeping
|
||||||
created = Column(DateTime, default=datetime.utcnow)
|
created = Column(DateTime, default=datetime.utcnow)
|
||||||
last_activity = Column(DateTime)
|
last_activity = Column(DateTime)
|
||||||
@@ -431,6 +435,10 @@ class OAuthAccessToken(Hashed, Base):
|
|||||||
__tablename__ = 'oauth_access_tokens'
|
__tablename__ = 'oauth_access_tokens'
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def api_id(self):
|
||||||
|
return 'o%i' % self.id
|
||||||
|
|
||||||
client_id = Column(Unicode(255), ForeignKey('oauth_clients.identifier', ondelete='CASCADE'))
|
client_id = Column(Unicode(255), ForeignKey('oauth_clients.identifier', ondelete='CASCADE'))
|
||||||
grant_type = Column(Enum(GrantType), nullable=False)
|
grant_type = Column(Enum(GrantType), nullable=False)
|
||||||
expires_at = Column(Integer)
|
expires_at = Column(Integer)
|
||||||
|
Reference in New Issue
Block a user