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 httpx import HTTPError
|
||||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
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.templating import Jinja2Templates
|
||||||
from fastapi.security import (
|
from fastapi.security import (
|
||||||
OAuth2PasswordBearer,
|
OAuth2PasswordBearer,
|
||||||
|
@ -219,6 +219,6 @@ async def home(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/private")
|
@app.get("/protected")
|
||||||
async def read_items(token: Annotated[str, Depends(get_current_user)]):
|
async def get_protected(user: Annotated[User, Depends(get_current_user)]):
|
||||||
return {"token": token}
|
return PlainTextResponse("Only authenticated users can see this")
|
||||||
|
|
|
@ -68,12 +68,20 @@
|
||||||
.login-toolbox a:hover {
|
.login-toolbox a:hover {
|
||||||
background-color: lightgreen;
|
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%;
|
font-size: 90%;
|
||||||
}
|
}
|
||||||
.debug p, .debug .key {
|
.debug-auth p, .debug .key {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.content {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -89,8 +97,10 @@
|
||||||
<span class="error">Cannot login: no oidc prodiver in settings.yaml</span>
|
<span class="error">Cannot login: no oidc prodiver in settings.yaml</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a class="link-to-protected" href="protected">
|
||||||
|
Ckeck here to get NOT_AUTHORIZED (401) or access protected content
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<a href="private">Private area, accessible only when Authorization is set (logged in)</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{% if user %}
|
{% if user %}
|
||||||
|
@ -103,7 +113,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user and settings.oidc.show_session_details %}
|
{% if user and settings.oidc.show_session_details %}
|
||||||
<div class="debug">
|
<div class="debug-auth">
|
||||||
<p>Session details:</p>
|
<p>Session details:</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for key, value in auth_data.items() %}
|
{% for key, value in auth_data.items() %}
|
||||||
|
@ -115,5 +125,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="content">
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue