diff options
author | Frederick Muriuki Muriithi | 2023-07-03 10:46:12 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-07-03 10:46:12 +0300 |
commit | 424a515120478998592663725d2d1186d36304f4 (patch) | |
tree | 0ab83cd5fee89c9db87620471b36f5f39b1f92c0 /gn3/auth/authentication | |
parent | 53d3a59c6f07f586a07438957869d834f36c4d11 (diff) | |
download | genenetwork3-424a515120478998592663725d2d1186d36304f4.tar.gz |
Enable deletion of OAuth2 clients.
Diffstat (limited to 'gn3/auth/authentication')
-rw-r--r-- | gn3/auth/authentication/oauth2/models/oauth2client.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gn3/auth/authentication/oauth2/models/oauth2client.py b/gn3/auth/authentication/oauth2/models/oauth2client.py index 564ed32..2a307e3 100644 --- a/gn3/auth/authentication/oauth2/models/oauth2client.py +++ b/gn3/auth/authentication/oauth2/models/oauth2client.py @@ -222,3 +222,13 @@ def oauth2_clients(conn: db.DbConnection) -> tuple[OAuth2Client, ...]: json.loads(result["client_metadata"]), the_users[UUID(result["user_id"])]) for result in clients_rs) + +def delete_client(conn: db.DbConnection, the_client: OAuth2Client) -> OAuth2Client: + """Delete the given client from the database""" + with db.cursor(conn) as cursor: + params = (str(the_client.client_id),) + cursor.execute("DELETE FROM authorisation_code WHERE client_id=?", + params) + cursor.execute("DELETE FROM oauth2_tokens WHERE client_id=?", params) + cursor.execute("DELETE FROM oauth2_clients WHERE client_id=?", params) + return the_client |