oidc-fastapi-test/src/templates/index.html
2025-01-02 03:09:16 +01:00

131 lines
3.2 KiB
HTML

<html>
<head>
<title>FastAPI OIDC test</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: antiquewhite;
}
h1 {
text-align: center;
}
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.user-info {
padding: 1em;
margin: 1em 0;
display: flex;
gap: 0.5em;
flex-direction: column;
width: fit-content;
align-items: center;
justify-content: center;
box-shadow: 0px 0px 10px lightgreen;
background-color: lightgreen;
}
.user-info * {
flex: 2 1 auto;
margin: 0;
}
.user-info .picture {
max-width: 3em;
max-height: 3em
}
.login-box {
text-align: center;
}
.login-toolbox {
max-width: 20em;
margin: auto;
display: flex;
flex-direction: column;
padding: 0 1em;
gap: 5px;
}
.login-toolbox a {
background-color: lightblue;
padding: 3px 6px;
text-decoration: none;
text-align: center;
color: black;
flex: 1 1 auto;
}
.login-toolbox .error {
color: darkred;
padding: 3px 6px;
text-align: center;
font-weight: bold;
flex: 1 1 auto;
}
.login-toolbox a.logout:hover {
background-color: orange;
}
.login-toolbox a:hover {
background-color: lightgreen;
}
.login-toolbox .link-to-protected {
margin: 1em;
background-color: cyan;
box-shadow: 0px 0px 20px cyan;
}
.debug-auth {
font-size: 90%;
}
.debug-auth p, .debug .key {
font-weight: bold;
}
.content {
text-align: left;
}
</style>
</head>
<body>
<h1>Test app for OIDC</h1>
<div class="login-box">
<div class="login-toolbox">
{% if user %}
<a href="logout" class="logout">Logout</a>
{% else %}
{% for provider in settings.oidc.providers %}
<a href="login?provider={{ provider.name }}">Login with: {{ provider.name }}</a>
{% else %}
<span class="error">Cannot login: no oidc prodiver in settings.yaml</span>
{% endfor %}
{% endif %}
<a class="link-to-protected" href="protected">
Ckeck here to get NOT_AUTHORIZED (401) or access protected content
</a>
</div>
</div>
<div class="content">
{% if user %}
<div class="user-info">
<p>Hey, {{ user.name }}</p>
{% if user.picture %}
<img src="{{ user.picture }}" class="picture"></img>
{% endif %}
<p>{{ user.email }}</p>
</div>
{% endif %}
{% if user and settings.oidc.show_session_details %}
<div class="debug-auth">
<p>Session details:</p>
<ul>
{% for key, value in auth_data.items() %}
<li>
<span class="key">{{ key }}</span>: {{ value }}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<div class="content">
</div>
</body>
</html>