From 424a515120478998592663725d2d1186d36304f4 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 3 Jul 2023 10:46:12 +0300 Subject: Enable deletion of OAuth2 clients. --- gn3/auth/authentication/oauth2/models/oauth2client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gn3/auth/authentication/oauth2') 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 -- cgit v1.2.3