Loading src/main.py +17 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ Federation Manager application import connexion from flask import render_template import encoder import yaml from flask_mongoengine import MongoEngine from configparser import ConfigParser Loading @@ -30,6 +31,9 @@ HOST = CONFIG.get("server", "host") PORT = int(CONFIG.get("server", "port")) MONGO_HOST = CONFIG.get("mongodb", "host") MONGO_PORT = CONFIG.get("mongodb", "port") KEYCLOAK_HOST = CONFIG.get("keycloak", "host") KEYCLOAK_PORT = int(CONFIG.get("keycloak", "port")) KEYCLOAK_REALM = CONFIG.get("keycloak", "realm") app = connexion.App(__name__, specification_dir='./swagger/') Loading @@ -46,8 +50,21 @@ def documentation(): """Endpoint to retrieve documentation""" return render_template("swaggerui.html") def edit_openapi_file(): with open("static/openapi.yaml", "r") as f: openapi_data = yaml.safe_load(f) token_url = f"http://{KEYCLOAK_HOST}:{KEYCLOAK_PORT}/realms/{KEYCLOAK_REALM}/protocol/openid-connect/token" # Update the tokenUrl openapi_data['components']['securitySchemes']['oAuth2ClientCredentials']['flows']['clientCredentials']['tokenUrl'] = token_url with open("static/openapi.yaml", "w") as f: yaml.dump(openapi_data, f) def main(): edit_openapi_file() app.run(host=HOST, port=PORT, threaded=True) Loading Loading
src/main.py +17 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ Federation Manager application import connexion from flask import render_template import encoder import yaml from flask_mongoengine import MongoEngine from configparser import ConfigParser Loading @@ -30,6 +31,9 @@ HOST = CONFIG.get("server", "host") PORT = int(CONFIG.get("server", "port")) MONGO_HOST = CONFIG.get("mongodb", "host") MONGO_PORT = CONFIG.get("mongodb", "port") KEYCLOAK_HOST = CONFIG.get("keycloak", "host") KEYCLOAK_PORT = int(CONFIG.get("keycloak", "port")) KEYCLOAK_REALM = CONFIG.get("keycloak", "realm") app = connexion.App(__name__, specification_dir='./swagger/') Loading @@ -46,8 +50,21 @@ def documentation(): """Endpoint to retrieve documentation""" return render_template("swaggerui.html") def edit_openapi_file(): with open("static/openapi.yaml", "r") as f: openapi_data = yaml.safe_load(f) token_url = f"http://{KEYCLOAK_HOST}:{KEYCLOAK_PORT}/realms/{KEYCLOAK_REALM}/protocol/openid-connect/token" # Update the tokenUrl openapi_data['components']['securitySchemes']['oAuth2ClientCredentials']['flows']['clientCredentials']['tokenUrl'] = token_url with open("static/openapi.yaml", "w") as f: yaml.dump(openapi_data, f) def main(): edit_openapi_file() app.run(host=HOST, port=PORT, threaded=True) Loading