aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-07-22 14:23:10 -0500
committerFrederick Muriuki Muriithi2024-07-22 14:23:44 -0500
commitcffe5bcd45edbd5113a687e7f5d3f24b298fd813 (patch)
treea917aac5dde18792031402cfaebd26aa2ae31770
parent60aa1e631739dd17e7b3fbe3b18f41a4f017f20b (diff)
downloadgenenetwork2-cffe5bcd45edbd5113a687e7f5d3f24b298fd813.tar.gz
Provide PoC public-jwks endpoint.
-rw-r--r--gn2/wqflask/oauth2/toplevel.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/gn2/wqflask/oauth2/toplevel.py b/gn2/wqflask/oauth2/toplevel.py
index f0179250..47b83ccf 100644
--- a/gn2/wqflask/oauth2/toplevel.py
+++ b/gn2/wqflask/oauth2/toplevel.py
@@ -3,10 +3,15 @@ import uuid
import datetime
from urllib.parse import urljoin, urlparse, urlunparse
-from authlib.jose import jwt
-from flask import (
- flash, request, Blueprint, url_for, redirect, render_template,
- current_app as app)
+from authlib.jose import jwt, KeySet
+from flask import (flash,
+ request,
+ url_for,
+ jsonify,
+ redirect,
+ Blueprint,
+ render_template,
+ current_app as app)
from . import session
from .checks import require_oauth2
@@ -80,3 +85,12 @@ def authorisation_code():
lambda err: __error__(process_error(err)), __success__)
flash("AuthorisationError: No code was provided.", "alert-danger")
return redirect("/")
+
+
+@toplevel.route("/public-jwks", methods=["GET"])
+def public_jwks():
+ """Provide endpoint that returns the public keys."""
+ return jsonify({
+ "documentation": "Returns a static key for the time being. This will change.",
+ "jwks": KeySet([app.config["SSL_PRIVATE_KEY"]]).as_dict().get("keys")
+ })