Continue refactor; fetch resources from the providers' settings
All checks were successful
/ build (push) Successful in 5s
/ test (push) Successful in 5s

This commit is contained in:
phil 2025-02-10 02:05:34 +01:00
parent c5bb4f4319
commit 496ce016e3
10 changed files with 217 additions and 113 deletions

View file

@ -5,25 +5,24 @@
with OpenID Connect and OAuth2 with different providers.
</p>
{% if not user %}
<div class="login-box">
<p class="description">Log in with:</p>
<table class="providers">
{% for provider in settings.auth.providers %}
<tr class="provider">
<td>
<a class="link" href="login/{{ provider.id }}"><div>{{ provider.name }}</div></a>
</td>
<td class="hint">{{ provider.hint }}</div>
</td>
</tr>
{% else %}
<div class="error">There is no authentication provider defined.
Hint: check the settings.yaml file.</div>
{% endfor %}
</table>
</div>
{% endif %}
{% if user %}
<div class="login-box">
<p class="description">Log in with:</p>
<table class="providers">
{% for provider in providers.values() %}
<tr class="provider">
<td>
<a class="link" href="login/{{ provider.id }}"><div>{{ provider.name }}</div></a>
</td>
<td class="hint">{{ provider.hint }}</div>
</td>
</tr>
{% else %}
<div class="error">There is no authentication provider defined.
Hint: check the settings.yaml file.</div>
{% endfor %}
</table>
</div>
{% else %}
<div class="user-info">
<p>Hey, {{ user.name }}</p>
{% if user.picture %}
@ -83,22 +82,22 @@
<button resource-id="fast_api_depends" class="hidden" onclick="get_resource('fast_api_depends', '{{ access_token }}', '{{ auth_provider.id }}')">Using FastAPI Depends</button>
<!--<button resource-id="introspect" onclick="get_resource('introspect', '{{ access_token }}', '{{ auth_provider.id }}')">Introspect token (401 expected)</button>-->
</div>
<div class="resourceResult">
<div id="resource" class="resource"></div>
<div id="msg" class="msg error"></div>
</div>
{% if resources %}
<p>
Resources for this provider:
</p>
<div class="links-to-check">
{% for resource in resources %}
<a href="{{ request.url_for('get_resource', id=resource.id) }}">{{ resource.name }}</a>
<button resource-id="{{ resource.id }}" onclick="get_resource('{{ resource.id }}', '{{ access_token }}', '{{ auth_provider.id }}')">{{ resource.name }}</buttona>
{% endfor %}
</div>
{% endif %}
<div class="resourceResult">
<div id="resource" class="resource"></div>
<div id="msg" class="msg error"></div>
</div>
</div>
{% if settings.show_token and id_token_parsed %}
{% if show_token and id_token_parsed %}
<div class="token-info">
<hr>
<div>

View file

@ -6,12 +6,12 @@
authorisation to log in again without asking for credentials.
</p>
<p>
This is because {{ oidc_provider.name }} does not provide "end_session_endpoint" in its metadata
(see: <a href="{{ oidc_provider._server_metadata_url }}">{{ oidc_provider._server_metadata_url }}</a>).
This is because {{ auth_provider.name }} does not provide "end_session_endpoint" in its metadata
(see: <a href="{{ auth_provider.authlib_client._server_metadata_url }}">{{ auth_provider.authlib_client._server_metadata_url }}</a>).
</p>
<p>
You can just also go back to the <a href="{{ home_url }}">application home page</a>, but
it recommended to go to the <a href="{{ oidc_provider.server_metadata['issuer'] }}">OIDC provider's site</a>
it recommended to go to the <a href="{{ auth_provider.authlib_client.server_metadata['issuer'] }}">OIDC provider's site</a>
and log out explicitely from there.
</p>
{% endblock %}