From 8a782ecdac0ca9b56c02a81f8978a05aa9c48be3 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 22 Jul 2024 14:23:10 -0500 Subject: Provide PoC public-jwks endpoint. --- gn2/wqflask/oauth2/toplevel.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'gn2') 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") + }) -- cgit v1.2.3