mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
add token_id to self
model
This commit is contained in:
@@ -1774,6 +1774,16 @@ components:
|
|||||||
example:
|
example:
|
||||||
- "read:users"
|
- "read:users"
|
||||||
- "access:servers!user=name"
|
- "access:servers!user=name"
|
||||||
|
token_id:
|
||||||
|
type:
|
||||||
|
- string
|
||||||
|
- "null"
|
||||||
|
description: |
|
||||||
|
The id of the token authorizing the request, if any.
|
||||||
|
This id can be used to revoke the token via the API.
|
||||||
|
Null if the request is not authorized with a token.
|
||||||
|
|
||||||
|
Added in 5.0.
|
||||||
Group:
|
Group:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@@ -63,10 +63,13 @@ class SelfAPIHandler(APIHandler):
|
|||||||
|
|
||||||
# add session_id associated with token
|
# add session_id associated with token
|
||||||
# added in 2.0
|
# added in 2.0
|
||||||
|
# token_id added in 5.0
|
||||||
token = self.get_token()
|
token = self.get_token()
|
||||||
if token:
|
if token:
|
||||||
|
model["token_id"] = token.api_id
|
||||||
model["session_id"] = token.session_id
|
model["session_id"] = token.session_id
|
||||||
else:
|
else:
|
||||||
|
model["token_id"] = None
|
||||||
model["session_id"] = None
|
model["session_id"] = None
|
||||||
|
|
||||||
# add scopes to identify model,
|
# add scopes to identify model,
|
||||||
|
@@ -600,6 +600,7 @@ async def test_get_self(app):
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
model = r.json()
|
model = r.json()
|
||||||
assert model['name'] == u.name
|
assert model['name'] == u.name
|
||||||
|
assert model["token_id"] == oauth_token.api_id
|
||||||
|
|
||||||
# invalid auth gets 403
|
# invalid auth gets 403
|
||||||
r = await api_request(
|
r = await api_request(
|
||||||
|
Reference in New Issue
Block a user