diff --git a/README.md b/README.md index 31f01da2ec8e9aa013e65215b76aed3506b2a928..694256eed5b2681db4cf8499cd5c9190016bc3cc 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,14 @@ Reloads metadata on inotify CLOSE_WRITE of metadata file. Serves and caches signed by domain signer from memory, on request ## ```mdproxy.py``` +Reads config from mdproxy.yaml configuration, see example. Caches signed and cached ```mdserver.py``` metadata requests ## Queries MDQ Queries can then be pointed at -- ```http://mdserver:5001/sign/<entityid>``` -- ```http://mdproxy:5002/cache/<entityid>``` +- ```http://mdserver:5001/<domain>/entities/<entityid>``` +- ```http://mdproxy:5002/<domain>/entities/<entityid>``` ## Bootstrap softHSM2 This is a very brief summary of the successive commands to initialize softHSM2 for testing. Tested on Ubuntu 21.10. diff --git a/mdproxy.py b/mdproxy.py index 284882336d14c2557b16cda184ee59fcd5e2eb9b..4a33146cef957a0e6d6e1dfb16c4a5f7020aee09 100755 --- a/mdproxy.py +++ b/mdproxy.py @@ -6,14 +6,14 @@ from urllib.parse import unquote from dateutil import parser, tz from datetime import datetime -from utils import hasher, Entity +from utils import read_config, hasher, Entity +config = read_config('mdproxy.yaml') app = Flask(__name__) # Find all IdP's in edugain metadata cached = {} -signer_url = 'http://localhost:5001' @app.route('/<domain>/entities/<path:eid>', methods=['GET']) @@ -35,7 +35,7 @@ def serve(domain, eid): return cached[domain][entityID].md else: print(f"request {entityID}") - data = requests.get(f"{signer_url}/{domain}/entities/{{sha1}}{entityID}").text + data = requests.get(f"{config[domain]['signer']}/{domain}/entities/{{sha1}}{entityID}").text try: parsed = ET.fromstring(data) validUntil = parsed.get('validUntil') diff --git a/mdproxy.yaml.example b/mdproxy.yaml.example new file mode 100644 index 0000000000000000000000000000000000000000..eef5eda2a25a0ea5aa4a4adb5cf1bf2b8638fb6d --- /dev/null +++ b/mdproxy.yaml.example @@ -0,0 +1,5 @@ +--- +test: + signer: 'http://localhost:5001' +foobar: + signer: 'http://localhost:5001' diff --git a/mdserver.py b/mdserver.py index b3dec1a9702450da92eef0d682d7a8233d49bb42..0ad714b1404e5eb7f05c69d613db9e608a632d21 100755 --- a/mdserver.py +++ b/mdserver.py @@ -2,7 +2,7 @@ from utils import read_config, Resource, Server from flask import Flask, Response -config = read_config() +config = read_config('mdserver.yaml') app = Flask(__name__) server = Server() @@ -31,4 +31,4 @@ for domain, values in config.items(): if __name__ == "__main__": - app.run(host='127.0.0.1', port=5001, debug=False) + app.run(host='0.0.0.0', port=5001, debug=False) diff --git a/utils.py b/utils.py index 860e3dd16a505b51ccdc2ca1d251b0edf2cce7ed..fbfa82e41f16e5c16ebe430b7c07faa45bcb7182 100755 --- a/utils.py +++ b/utils.py @@ -13,8 +13,8 @@ from signers import Signers # watch_manager = pyinotify.WatchManager() -def read_config(): - with open('mdserver.yaml') as f: +def read_config(config): + with open(config) as f: config = yaml.safe_load(f) return config