diff --git a/Dockerfile b/Dockerfile index fb476858..fb020019 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,5 +20,4 @@ HEALTHCHECK --interval=10s --timeout=5s --start-period=5s --retries=3 \ EXPOSE 9000 -# CMD ["/app/run.sh"] -CMD ["python", "app.py"] +CMD ["/app/run.sh"] diff --git a/app.py b/app.py index dba2c97c..6bc05032 100644 --- a/app.py +++ b/app.py @@ -3,4 +3,4 @@ app = create_app() if __name__ == "__main__": - app.run(port=9000) + app.run(host="0.0.0.0", port=9000) diff --git a/labconnect/helpers.py b/labconnect/helpers.py index a7f1bbe3..57467631 100644 --- a/labconnect/helpers.py +++ b/labconnect/helpers.py @@ -79,10 +79,12 @@ def serializeOpportunity(data): def prepare_flask_request(request): # If server is behind proxys or balancers use the HTTP_X_FORWARDED fields + url_data = request.host_url + request.script_root return { "https": "on" if request.scheme == "https" else "off", "http_host": request.host, "script_name": request.path, + "server_port": url_data.split(":")[1] if ":" in url_data else "80", "get_data": request.args.copy(), # Uncomment if using ADFS as IdP, https://github.com/onelogin/python-saml/pull/144 # 'lowercase_urlencoding': True, diff --git a/labconnect/main/auth_routes.py b/labconnect/main/auth_routes.py index e54fe202..8ad0626a 100644 --- a/labconnect/main/auth_routes.py +++ b/labconnect/main/auth_routes.py @@ -75,15 +75,10 @@ def saml_login(): @main_blueprint.post("/callback") def saml_callback(): # Process SAML response - print("HERE") req = prepare_flask_request(request) - print("req", req) auth = OneLogin_Saml2_Auth(req, custom_base_path=current_app.config["SAML_CONFIG"]) - print("auth", auth) auth.process_response() - print("auth", auth) errors = auth.get_errors() - print("errors", errors) if not errors: registered = True @@ -102,7 +97,8 @@ def saml_callback(): # Send the JWT to the frontend return redirect(f"{current_app.config['FRONTEND_URL']}/callback/?code={code}") - return {"errors": errors}, 500 + error_reason = auth.get_last_error_reason() + return {"errors": errors, "error_reason": error_reason}, 500 @main_blueprint.post("/register")