Cosmetic
This commit is contained in:
parent
e98b785a63
commit
3e3db42468
2 changed files with 21 additions and 9 deletions
|
@ -5,7 +5,7 @@ from json import dumps
|
|||
|
||||
from httpx import HTTPError
|
||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse, PlainTextResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi.security import (
|
||||
OAuth2PasswordBearer,
|
||||
|
@ -219,6 +219,6 @@ async def home(
|
|||
)
|
||||
|
||||
|
||||
@app.get("/private")
|
||||
async def read_items(token: Annotated[str, Depends(get_current_user)]):
|
||||
return {"token": token}
|
||||
@app.get("/protected")
|
||||
async def get_protected(user: Annotated[User, Depends(get_current_user)]):
|
||||
return PlainTextResponse("Only authenticated users can see this")
|
||||
|
|
|
@ -68,12 +68,20 @@
|
|||
.login-toolbox a:hover {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
.debug {
|
||||
.login-toolbox .link-to-protected {
|
||||
margin: 1em;
|
||||
background-color: cyan;
|
||||
box-shadow: 0px 0px 20px cyan;
|
||||
}
|
||||
.debug-auth {
|
||||
font-size: 90%;
|
||||
}
|
||||
.debug p, .debug .key {
|
||||
.debug-auth p, .debug .key {
|
||||
font-weight: bold;
|
||||
}
|
||||
.content {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -84,13 +92,15 @@
|
|||
<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>
|
||||
<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>
|
||||
<a href="private">Private area, accessible only when Authorization is set (logged in)</a>
|
||||
</div>
|
||||
<div class="content">
|
||||
{% if user %}
|
||||
|
@ -103,7 +113,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
{% if user and settings.oidc.show_session_details %}
|
||||
<div class="debug">
|
||||
<div class="debug-auth">
|
||||
<p>Session details:</p>
|
||||
<ul>
|
||||
{% for key, value in auth_data.items() %}
|
||||
|
@ -115,5 +125,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="content">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue