mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-10 19:43:01 +00:00
Merge pull request #2155 from minrk/cleanup-client-fix
fix oauth client cleanup
This commit is contained in:
@@ -9,6 +9,12 @@ command line for details.
|
|||||||
|
|
||||||
## 0.9
|
## 0.9
|
||||||
|
|
||||||
|
### [0.9.4] 2018-09-20
|
||||||
|
|
||||||
|
JupyterHub 0.9.4 fixes a single issue that required
|
||||||
|
all running user servers to be restarted when performing an upgrade
|
||||||
|
from 0.8 to 0.9.
|
||||||
|
|
||||||
### [0.9.3] 2018-09-12
|
### [0.9.3] 2018-09-12
|
||||||
|
|
||||||
JupyterHub 0.9.3 contains small bugfixes and improvements
|
JupyterHub 0.9.3 contains small bugfixes and improvements
|
||||||
@@ -417,7 +423,8 @@ Fix removal of `/login` page in 0.4.0, breaking some OAuth providers.
|
|||||||
First preview release
|
First preview release
|
||||||
|
|
||||||
|
|
||||||
[Unreleased]: https://github.com/jupyterhub/jupyterhub/compare/0.9.3...HEAD
|
[Unreleased]: https://github.com/jupyterhub/jupyterhub/compare/0.9.4...HEAD
|
||||||
|
[0.9.4]: https://github.com/jupyterhub/jupyterhub/compare/0.9.3...0.9.4
|
||||||
[0.9.3]: https://github.com/jupyterhub/jupyterhub/compare/0.9.2...0.9.3
|
[0.9.3]: https://github.com/jupyterhub/jupyterhub/compare/0.9.2...0.9.3
|
||||||
[0.9.2]: https://github.com/jupyterhub/jupyterhub/compare/0.9.1...0.9.2
|
[0.9.2]: https://github.com/jupyterhub/jupyterhub/compare/0.9.1...0.9.2
|
||||||
[0.9.1]: https://github.com/jupyterhub/jupyterhub/compare/0.9.0...0.9.1
|
[0.9.1]: https://github.com/jupyterhub/jupyterhub/compare/0.9.0...0.9.1
|
||||||
|
@@ -1506,6 +1506,10 @@ class JupyterHub(Application):
|
|||||||
for user in self.users.values():
|
for user in self.users.values():
|
||||||
for spawner in user.spawners.values():
|
for spawner in user.spawners.values():
|
||||||
oauth_client_ids.add(spawner.oauth_client_id)
|
oauth_client_ids.add(spawner.oauth_client_id)
|
||||||
|
# avoid deleting clients created by 0.8
|
||||||
|
# 0.9 uses `jupyterhub-user-...` for the client id, while
|
||||||
|
# 0.8 uses just `user-...`
|
||||||
|
oauth_client_ids.add(spawner.oauth_client_id.split('-', 1)[1])
|
||||||
|
|
||||||
for i, oauth_client in enumerate(self.db.query(orm.OAuthClient)):
|
for i, oauth_client in enumerate(self.db.query(orm.OAuthClient)):
|
||||||
if oauth_client.identifier not in oauth_client_ids:
|
if oauth_client.identifier not in oauth_client_ids:
|
||||||
|
@@ -554,11 +554,25 @@ class User:
|
|||||||
# remove server entry from db
|
# remove server entry from db
|
||||||
spawner.server = None
|
spawner.server = None
|
||||||
if not spawner.will_resume:
|
if not spawner.will_resume:
|
||||||
# find and remove the API token if the spawner isn't
|
# find and remove the API token and oauth client if the spawner isn't
|
||||||
# going to re-use it next time
|
# going to re-use it next time
|
||||||
orm_token = orm.APIToken.find(self.db, api_token)
|
orm_token = orm.APIToken.find(self.db, api_token)
|
||||||
if orm_token:
|
if orm_token:
|
||||||
self.db.delete(orm_token)
|
self.db.delete(orm_token)
|
||||||
|
# remove oauth client as well
|
||||||
|
# handle upgrades from 0.8, where client id will be `user-USERNAME`,
|
||||||
|
# not just `jupyterhub-user-USERNAME`
|
||||||
|
client_ids = (
|
||||||
|
spawner.oauth_client_id,
|
||||||
|
spawner.oauth_client_id.split('-', 1)[1],
|
||||||
|
)
|
||||||
|
for oauth_client in (
|
||||||
|
self.db
|
||||||
|
.query(orm.OAuthClient)
|
||||||
|
.filter(orm.OAuthClient.identifier.in_(client_ids))
|
||||||
|
):
|
||||||
|
self.log.debug("Deleting oauth client %s", oauth_client.identifier)
|
||||||
|
self.db.delete(oauth_client)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
finally:
|
finally:
|
||||||
spawner.orm_spawner.started = None
|
spawner.orm_spawner.started = None
|
||||||
|
Reference in New Issue
Block a user