2025-01-09 23:41:32 +01:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
2025-01-10 23:40:24 +01:00
|
|
|
<style>
|
|
|
|
.login-box {
|
|
|
|
text-align: center;
|
2025-01-13 17:01:11 +01:00
|
|
|
background-color: antiquewhite;
|
|
|
|
margin: 0.5em auto;
|
2025-01-10 23:40:24 +01:00
|
|
|
width: fit-content;
|
2025-01-13 17:01:11 +01:00
|
|
|
box-shadow: 0 0 10px #49759b88;
|
|
|
|
border-radius: 8px;
|
2025-01-10 23:40:24 +01:00
|
|
|
}
|
|
|
|
.login-box .description {
|
|
|
|
font-style: italic;
|
2025-01-13 17:01:11 +01:00
|
|
|
font-weight: bold;
|
|
|
|
background-color: #f7c7867d;
|
|
|
|
padding: 6px;
|
|
|
|
margin: 0;
|
|
|
|
border-radius: 8px 8px 0 0;
|
2025-01-10 23:40:24 +01:00
|
|
|
}
|
|
|
|
.providers {
|
|
|
|
justify-content: center;
|
|
|
|
padding: 0.8em;
|
|
|
|
}
|
|
|
|
.providers .provider {
|
2025-01-11 03:54:53 +01:00
|
|
|
min-height: 2em;
|
|
|
|
}
|
|
|
|
.providers .provider a.link {
|
|
|
|
text-decoration: none;
|
2025-01-13 17:01:11 +01:00
|
|
|
max-height: 2em;
|
2025-01-10 23:40:24 +01:00
|
|
|
}
|
2025-01-11 03:54:53 +01:00
|
|
|
.providers .provider .link div {
|
|
|
|
text-align: center;
|
2025-01-13 17:01:11 +01:00
|
|
|
background-color: #f7c7867d;
|
2025-01-10 23:40:24 +01:00
|
|
|
border-radius: 8px;
|
|
|
|
padding: 6px;
|
|
|
|
text-align: center;
|
|
|
|
color: black;
|
|
|
|
font-weight: bold;
|
2025-01-11 03:54:53 +01:00
|
|
|
cursor: pointer;
|
2025-01-10 23:40:24 +01:00
|
|
|
}
|
|
|
|
.providers .provider .hint {
|
|
|
|
font-size: 80%;
|
2025-01-13 17:01:11 +01:00
|
|
|
max-width: 13em;
|
2025-01-10 23:40:24 +01:00
|
|
|
}
|
|
|
|
.providers .error {
|
|
|
|
color: darkred;
|
|
|
|
padding: 3px 6px;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bold;
|
|
|
|
flex: 1 1 auto;
|
|
|
|
}
|
|
|
|
</style>
|
2025-01-10 19:03:09 +01:00
|
|
|
<p class="center">
|
2025-01-11 03:54:53 +01:00
|
|
|
Test the authentication and authorization,
|
2025-01-10 19:03:09 +01:00
|
|
|
with OpenID Connect and OAuth2 with different providers.
|
|
|
|
</p>
|
2025-01-09 23:41:32 +01:00
|
|
|
{% if not user %}
|
|
|
|
<div class="login-box">
|
2025-01-13 17:01:11 +01:00
|
|
|
<p class="description">Log in with:</p>
|
2025-01-10 23:40:24 +01:00
|
|
|
<table class="providers">
|
2025-01-10 19:03:09 +01:00
|
|
|
{% for provider in settings.oidc.providers %}
|
2025-01-10 23:40:24 +01:00
|
|
|
<tr class="provider">
|
2025-01-11 03:54:53 +01:00
|
|
|
<td>
|
|
|
|
<a class="link" href="login/{{ provider.id }}"><div>{{ provider.name }}</div></a>
|
2025-01-10 23:40:24 +01:00
|
|
|
</td>
|
|
|
|
<td class="hint">{{ provider.hint }}</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2025-01-10 19:03:09 +01:00
|
|
|
{% else %}
|
2025-01-10 23:40:24 +01:00
|
|
|
<div class="error">There is no authentication provider defined.
|
|
|
|
Hint: check the settings.yaml file.</div>
|
2025-01-10 19:03:09 +01:00
|
|
|
{% endfor %}
|
2025-01-10 23:40:24 +01:00
|
|
|
</table>
|
2025-01-09 23:41:32 +01:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
{% if user %}
|
|
|
|
<div class="user-info">
|
|
|
|
<p>Hey, {{ user.name }}</p>
|
|
|
|
{% if user.picture %}
|
|
|
|
<img src="{{ user.picture }}" class="picture"></img>
|
|
|
|
{% endif %}
|
|
|
|
<div>{{ user.email }}</div>
|
|
|
|
{% if user.roles %}
|
|
|
|
<div>
|
|
|
|
<span>Roles:</span>
|
|
|
|
{% for role in user.roles %}
|
|
|
|
<span class="role">{{ role.name }}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
<div>
|
|
|
|
<span>Provider:</span>
|
|
|
|
{{ user.oidc_provider.name }}
|
|
|
|
</div>
|
|
|
|
<a href="logout" class="logout">Logout</a>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2025-01-10 19:03:09 +01:00
|
|
|
<hr>
|
2025-01-09 23:41:32 +01:00
|
|
|
<div class="content">
|
|
|
|
<p>
|
|
|
|
These links should get different response codes depending on the authorization:
|
|
|
|
</p>
|
|
|
|
<div id="links-to-check">
|
|
|
|
<a href="public">Public</a>
|
|
|
|
<a href="protected">Auth protected content</a>
|
|
|
|
<a href="protected-by-foorole">Auth + foorole protected content</a>
|
|
|
|
<a href="protected-by-foorole-or-barrole">Auth + foorole or barrole protected content</a>
|
|
|
|
<a href="protected-by-barrole">Auth + barrole protected content</a>
|
|
|
|
<a href="protected-by-foorole-and-barrole">Auth + foorole and barrole protected content</a>
|
2025-01-10 17:33:10 +01:00
|
|
|
<a href="fast_api_depends" class="hidden">Using FastAPI Depends</a>
|
2025-01-09 23:41:32 +01:00
|
|
|
<a href="other">Other</a>
|
|
|
|
</div>
|
|
|
|
{% if user_info_details %}
|
|
|
|
<div class="debug-auth">
|
|
|
|
<p>User info</p>
|
|
|
|
<ul>
|
|
|
|
{% for key, value in user_info_details.items() %}
|
|
|
|
<li>
|
|
|
|
<span class="key">{{ key }}</span>: {{ value }}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div>Now is: {{ now }}</div>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
{% endblock %}
|