add description to oauth clients for services and user servers

This commit is contained in:
Min RK
2018-04-13 10:56:17 +02:00
parent 8dc73a852d
commit be5a878da5
3 changed files with 7 additions and 4 deletions

View File

@@ -1222,6 +1222,7 @@ class JupyterHub(Application):
client_id=service.oauth_client_id, client_id=service.oauth_client_id,
client_secret=service.api_token, client_secret=service.api_token,
redirect_uri=service.oauth_redirect_uri, redirect_uri=service.oauth_redirect_uri,
description="JupyterHub service %s" % service.name,
) )
self._service_map[name] = service self._service_map[name] = service

View File

@@ -196,7 +196,7 @@ class ClientStore(HubDBMixin, oauth2.store.ClientStore):
secret=HashComparable(orm_client.secret), secret=HashComparable(orm_client.secret),
) )
def add_client(self, client_id, client_secret, redirect_uri): def add_client(self, client_id, client_secret, redirect_uri, description=''):
"""Add a client """Add a client
hash its client_secret before putting it in the database. hash its client_secret before putting it in the database.
@@ -212,6 +212,7 @@ class ClientStore(HubDBMixin, oauth2.store.ClientStore):
identifier=client_id, identifier=client_id,
secret=hash_token(client_secret), secret=hash_token(client_secret),
redirect_uri=redirect_uri, redirect_uri=redirect_uri,
description=description,
) )
self.db.add(orm_client) self.db.add(orm_client)
self.db.commit() self.db.commit()

View File

@@ -381,6 +381,7 @@ class User:
# containers that resume will be updated below # containers that resume will be updated below
client_store.add_client(client_id, api_token, client_store.add_client(client_id, api_token,
url_path_join(self.url, server_name, 'oauth_callback'), url_path_join(self.url, server_name, 'oauth_callback'),
description="Server at %s" % url_path_join(self.url, server_name),
) )
db.commit() db.commit()