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"])
def auth() -> str:
"""Accepts a series of parameters."""
host_url = current_app.config.get("SPIFFWORKFLOW_BACKEND_URL") or request.host_url.strip("/")
return render_template(
"login.html",
state=request.args.get("state"),
@ -63,6 +64,7 @@ def auth() -> str:
scope=request.args.get("scope"),
redirect_uri=request.args.get("redirect_uri"),
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)
return redirect(url)
else:
host_url = current_app.config.get("SPIFFWORKFLOW_BACKEND_URL") or request.host_url.strip("/")
return render_template(
"login.html",
state=request.values.get("state"),
@ -89,6 +92,7 @@ def form_submit() -> Any:
scope=request.values.get("scope"),
redirect_uri=request.values.get("redirect_uri"),
error_message="Login failed. Please try again.",
host_url=host_url,
)

View File

@ -1,38 +1,70 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<head>
<title>Login Form</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('openid.static', filename='login.css') }}">
</head>
<body>
<link
rel="stylesheet"
type="text/css"
href="{{ host_url }}/{{ url_for('openid.static', filename='login.css') }}"
/>
</head>
<body>
<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>
<h2>Login</h2>
<div class="error">{{error_message}}</div>
<div class="login">
<form id="login" method="post" action="{{ url_for('openid.form_submit') }}">
<p><b>Important:</b> This login form is for demonstration purposes only. In production systems you should
be using a real Open ID System.</p>
<input type="text" class="cds--text-input" name="Uname" 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>
<form
id="login"
method="post"
action="{{ host_url }}/{{ url_for('openid.form_submit') }}"
>
<p>
<b>Important:</b> This login form is for demonstration purposes only.
In production systems you should be using a real Open ID System.
</p>
<input
type="text"
class="cds--text-input"
name="Uname"
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.
<input type="checkbox" id="check">
<span>Remember me</span>
<br><br>
Forgot <a href="#">Password</a>
-->
</form>
</div>
</body>
</form>
</div>
</body>
</html>