use backend url in local openid login page w/ burnettk

This commit is contained in:
jasquat 2024-04-03 16:52:25 -04:00
parent 12e7cecd97
commit 927f150d4f
No known key found for this signature in database
2 changed files with 59 additions and 23 deletions

View File

@ -55,6 +55,7 @@ def well_known() -> dict:
@openid_blueprint.route("/auth", methods=["GET"]) @openid_blueprint.route("/auth", methods=["GET"])
def auth() -> str: def auth() -> str:
"""Accepts a series of parameters.""" """Accepts a series of parameters."""
host_url = current_app.config.get("SPIFFWORKFLOW_BACKEND_URL") or request.host_url.strip("/")
return render_template( return render_template(
"login.html", "login.html",
state=request.args.get("state"), state=request.args.get("state"),
@ -63,6 +64,7 @@ def auth() -> str:
scope=request.args.get("scope"), scope=request.args.get("scope"),
redirect_uri=request.args.get("redirect_uri"), redirect_uri=request.args.get("redirect_uri"),
error_message=request.args.get("error_message", ""), error_message=request.args.get("error_message", ""),
host_url=host_url,
) )
@ -81,6 +83,7 @@ def form_submit() -> Any:
url = request.values.get("redirect_uri") + "?" + urlencode(data) url = request.values.get("redirect_uri") + "?" + urlencode(data)
return redirect(url) return redirect(url)
else: else:
host_url = current_app.config.get("SPIFFWORKFLOW_BACKEND_URL") or request.host_url.strip("/")
return render_template( return render_template(
"login.html", "login.html",
state=request.values.get("state"), state=request.values.get("state"),
@ -89,6 +92,7 @@ def form_submit() -> Any:
scope=request.values.get("scope"), scope=request.values.get("scope"),
redirect_uri=request.values.get("redirect_uri"), redirect_uri=request.values.get("redirect_uri"),
error_message="Login failed. Please try again.", error_message="Login failed. Please try again.",
host_url=host_url,
) )

View File

@ -1,38 +1,70 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<title>Login Form</title> <title>Login Form</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('openid.static', filename='login.css') }}"> <link
</head> rel="stylesheet"
<body> type="text/css"
href="{{ host_url }}/{{ url_for('openid.static', filename='login.css') }}"
/>
</head>
<body>
<header> <header>
<img class="logo_small" src="{{ url_for('openid.static', filename='logo_small.png') }}" alt="Small SpiffWorkflow logo" /> <img
class="logo_small"
src="{{ host_url }}/{{ url_for('openid.static', filename='logo_small.png') }}"
alt="Small SpiffWorkflow logo"
/>
</header> </header>
<h2>Login</h2> <h2>Login</h2>
<div class="error">{{error_message}}</div> <div class="error">{{error_message}}</div>
<div class="login"> <div class="login">
<form id="login" method="post" action="{{ url_for('openid.form_submit') }}"> <form
<p><b>Important:</b> This login form is for demonstration purposes only. In production systems you should id="login"
be using a real Open ID System.</p> method="post"
<input type="text" class="cds--text-input" name="Uname" id="username" placeholder="Username"> action="{{ host_url }}/{{ url_for('openid.form_submit') }}"
<br><br> >
<input type="Password" class="cds--text-input" name="Pass" id="password" placeholder="Password"> <p>
<br><br> <b>Important:</b> This login form is for demonstration purposes only.
<input type="hidden" name="state" value="{{state}}"/> In production systems you should be using a real Open ID System.
<input type="hidden" name="response_type" value="{{response_type}}"/> </p>
<input type="hidden" name="client_id" value="{{client_id}}"/> <input
<input type="hidden" name="scope" value="{{scope}}"/> type="text"
<input type="hidden" name="redirect_uri" value="{{redirect_uri}}"/> class="cds--text-input"
<input type="submit" name="log" class="cds--btn cds--btn--primary" id="spiff-login-button" value="Log In"> name="Uname"
<br><br> id="username"
placeholder="Username"
/>
<br /><br />
<input
type="Password"
class="cds--text-input"
name="Pass"
id="password"
placeholder="Password"
/>
<br /><br />
<input type="hidden" name="state" value="{{state}}" />
<input type="hidden" name="response_type" value="{{response_type}}" />
<input type="hidden" name="client_id" value="{{client_id}}" />
<input type="hidden" name="scope" value="{{scope}}" />
<input type="hidden" name="redirect_uri" value="{{redirect_uri}}" />
<input
type="submit"
name="log"
class="cds--btn cds--btn--primary"
id="spiff-login-button"
value="Log In"
/>
<br /><br />
<!-- should maybe add this stuff in eventually, but this is just for testing. <!-- should maybe add this stuff in eventually, but this is just for testing.
<input type="checkbox" id="check"> <input type="checkbox" id="check">
<span>Remember me</span> <span>Remember me</span>
<br><br> <br><br>
Forgot <a href="#">Password</a> Forgot <a href="#">Password</a>
--> -->
</form> </form>
</div> </div>
</body> </body>
</html> </html>