aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authorisation
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-06-30 09:19:39 +0300
committerFrederick Muriuki Muriithi2023-06-30 09:19:39 +0300
commitcd16f99aa23123f2398e3a3a542d84363d7a7b16 (patch)
tree019eadec715989ee80cc62f5f78070d54dc8c75d /gn3/auth/authorisation
parentd46d1eb47f9ee18518894d850a18cd952231dddc (diff)
downloadgenenetwork3-cd16f99aa23123f2398e3a3a542d84363d7a7b16.tar.gz
List all OAuth2 clients.
Diffstat (limited to 'gn3/auth/authorisation')
-rw-r--r--gn3/auth/authorisation/users/admin/views.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/gn3/auth/authorisation/users/admin/views.py b/gn3/auth/authorisation/users/admin/views.py
index ee76354..11152d2 100644
--- a/gn3/auth/authorisation/users/admin/views.py
+++ b/gn3/auth/authorisation/users/admin/views.py
@@ -1,5 +1,6 @@
"""UI for admin stuff"""
import uuid
+import json
import random
import string
from functools import partial
@@ -22,7 +23,8 @@ from gn3.auth.db_utils import with_db_connection
from gn3.auth.authentication.oauth2.models.oauth2client import (
save_client,
- OAuth2Client)
+ OAuth2Client,
+ oauth2_clients)
from gn3.auth.authentication.users import (
User,
user_by_id,
@@ -44,6 +46,7 @@ def update_expires():
return None
@admin.route("/dashboard", methods=["GET"])
+@is_admin
def dashboard():
"""Admin dashboard."""
return render_template("admin/dashboard.html")
@@ -151,3 +154,18 @@ def register_client():
"admin/registered-client.html",
client=client,
client_secret = raw_client_secret)
+
+def __parse_client__(sqlite3Row) -> dict:
+ """Parse the client details into python datatypes."""
+ return {
+ **dict(sqlite3Row),
+ "client_metadata": json.loads(sqlite3Row["client_metadata"])
+ }
+
+@admin.route("/list-client", methods=["GET"])
+@is_admin
+def list_clients():
+ """List all registered OAuth2 clients."""
+ return render_template(
+ "admin/list-oauth2-clients.html",
+ clients=with_db_connection(oauth2_clients))