mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 22:43:00 +00:00
Revoking one oauth token revokes all oauth tokens for that client
This commit is contained in:
@@ -283,6 +283,16 @@ class UserTokenAPIHandler(APIHandler):
|
|||||||
if not user:
|
if not user:
|
||||||
raise web.HTTPError(404, "No such user: %s" % name)
|
raise web.HTTPError(404, "No such user: %s" % name)
|
||||||
token = self.find_token_by_id(user, token_id)
|
token = self.find_token_by_id(user, token_id)
|
||||||
|
# deleting an oauth token deletes *all* oauth tokens for that client
|
||||||
|
if isinstance(token, orm.OAuthAccessToken):
|
||||||
|
client_id = token.client_id
|
||||||
|
tokens = [
|
||||||
|
token for token in user.oauth_tokens
|
||||||
|
if token.client_id == client_id
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
tokens = [token]
|
||||||
|
for token in tokens:
|
||||||
self.db.delete(token)
|
self.db.delete(token)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
self.set_header('Content-Type', 'text/plain')
|
self.set_header('Content-Type', 'text/plain')
|
||||||
|
@@ -254,13 +254,16 @@ class TokenPageHandler(BaseHandler):
|
|||||||
(token.last_activity and token.last_activity > last_activity)
|
(token.last_activity and token.last_activity > last_activity)
|
||||||
):
|
):
|
||||||
last_activity = token.last_activity
|
last_activity = token.last_activity
|
||||||
|
token = tokens[0]
|
||||||
oauth_clients.append({
|
oauth_clients.append({
|
||||||
'client': token.client,
|
'client': token.client,
|
||||||
'description': token.client.description or token.client.client_id,
|
'description': token.client.description or token.client.client_id,
|
||||||
'created': created,
|
'created': created,
|
||||||
'last_activity': last_activity,
|
'last_activity': last_activity,
|
||||||
'tokens': tokens,
|
'tokens': tokens,
|
||||||
'token_ids': ','.join(token.api_id for token in tokens),
|
# only need one token id because
|
||||||
|
# revoking one oauth token revokes all oauth tokens for that client
|
||||||
|
'token_id': tokens[0].api_id,
|
||||||
'token_count': len(tokens),
|
'token_count': len(tokens),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -71,7 +71,7 @@
|
|||||||
{{ token.created.isoformat() + 'Z' }}
|
{{ token.created.isoformat() + 'Z' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="col-sm-1 text-center">
|
<td class="col-sm-1 text-center">
|
||||||
<a role="button" class="revoke-token-btn btn btn-xs btn-danger">revoke</a>
|
<button class="revoke-token-btn btn btn-xs btn-danger">revoke</button>
|
||||||
</td>
|
</td>
|
||||||
{% endblock token_row %}
|
{% endblock token_row %}
|
||||||
</tr>
|
</tr>
|
||||||
@@ -87,20 +87,16 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Application</td>
|
<td>Application</td>
|
||||||
<td>Tokens</td>
|
|
||||||
<td>Last used</td>
|
<td>Last used</td>
|
||||||
<td>First authorized</td>
|
<td>First authorized</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for client in oauth_clients %}
|
{% for client in oauth_clients %}
|
||||||
<tr class="oauth-client-row"
|
<tr class="token-row"
|
||||||
data-token-ids="{{ client['token_ids'] }}"">
|
data-token-id="{{ client['token_id'] }}"">
|
||||||
{% block client_row scoped %}
|
{% block client_row scoped %}
|
||||||
<td class="note-col col-sm-4">{{ client['description'] }}</td>
|
<td class="note-col col-sm-5">{{ client['description'] }}</td>
|
||||||
<td class="col-sm-1">
|
|
||||||
{{ client['token_count'] }}
|
|
||||||
</td>
|
|
||||||
<td class="time-col col-sm-3">
|
<td class="time-col col-sm-3">
|
||||||
{%- if client['last_activity'] -%}
|
{%- if client['last_activity'] -%}
|
||||||
{{ client['last_activity'].isoformat() + 'Z' }}
|
{{ client['last_activity'].isoformat() + 'Z' }}
|
||||||
@@ -112,8 +108,8 @@
|
|||||||
{{ client['created'].isoformat() + 'Z' }}
|
{{ client['created'].isoformat() + 'Z' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="col-sm-1 text-center">
|
<td class="col-sm-1 text-center">
|
||||||
<a role="button" class="delete-token-btn btn btn-xs btn-danger">revoke</a>
|
<button class="revoke-token-btn btn btn-xs btn-danger">revoke</a>
|
||||||
</td>
|
</button>
|
||||||
{% endblock client_row %}
|
{% endblock client_row %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Reference in New Issue
Block a user