From f0d63bed22163247357fac9a0dc38b35dc991ea0 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Thu, 20 Nov 2025 19:44:00 +1100 Subject: [PATCH] Allow creation of api keys scoped to functions --- routes/settings.py | 8 ++++++-- templates/dashboard/settings/api_keys.html | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/routes/settings.py b/routes/settings.py index 74395c8..481b2bd 100644 --- a/routes/settings.py +++ b/routes/settings.py @@ -18,14 +18,18 @@ def api_keys(): if isinstance(key['scopes'], str): key['scopes'] = json.loads(key['scopes']) + # Fetch user's functions for scoping + functions = db.get_http_functions_for_user(user_id) + if htmx: return render_block( environment, "dashboard/settings/api_keys.html", "page", - api_keys=api_keys + api_keys=api_keys, + functions=functions ) - return render_template("dashboard/settings/api_keys.html", api_keys=api_keys) + return render_template("dashboard/settings/api_keys.html", api_keys=api_keys, functions=functions) @settings.route("/api-keys", methods=["POST"]) @login_required diff --git a/templates/dashboard/settings/api_keys.html b/templates/dashboard/settings/api_keys.html index ff13a6c..e82699c 100644 --- a/templates/dashboard/settings/api_keys.html +++ b/templates/dashboard/settings/api_keys.html @@ -96,9 +96,21 @@ class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"> Full Access (*) - + +
+

Or limit to specific functions:

+
+ {% for function in functions %} + + {% endfor %} +
+
-

Currently only full access is supported via UI.

+

Select "Full Access" or specific functions.