Major refactor of frontend source tree such that paths better match where they are served.
This commit is contained in:
+1
-1
@@ -439,7 +439,7 @@ class DB(DatabaseInterface):
|
||||
credential_model = result.scalar_one_or_none()
|
||||
|
||||
if not credential_model:
|
||||
raise ValueError("This passkey is not registered with this service")
|
||||
raise ValueError("Credential not found")
|
||||
return Credential(
|
||||
uuid=UUID(bytes=credential_model.uuid),
|
||||
credential_id=credential_model.credential_id,
|
||||
|
||||
@@ -36,7 +36,7 @@ async def general_exception_handler(_request, exc: Exception):
|
||||
|
||||
@app.get("/")
|
||||
async def adminapp(request: Request, auth=AUTH_COOKIE):
|
||||
return FileResponse(frontend.file("admin/index.html"))
|
||||
return FileResponse(frontend.file("auth", "admin", "index.html"))
|
||||
|
||||
|
||||
# -------------------- Organizations --------------------
|
||||
|
||||
@@ -10,7 +10,7 @@ from fastapi import (
|
||||
Request,
|
||||
Response,
|
||||
)
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.security import HTTPBearer
|
||||
|
||||
from passkey.util import frontend
|
||||
@@ -36,12 +36,6 @@ app = FastAPI()
|
||||
app.mount("/user", user.app)
|
||||
|
||||
|
||||
@app.get("/restricted")
|
||||
async def restricted_view():
|
||||
"""Serve the restricted/authentication UI for iframe embedding."""
|
||||
return FileResponse(frontend.file("restricted/api", "index.html"))
|
||||
|
||||
|
||||
@app.exception_handler(HTTPException)
|
||||
async def http_exception_handler(_request: Request, exc: HTTPException):
|
||||
"""Ensure auth cookie is cleared on 401 responses (JSON responses only)."""
|
||||
@@ -155,7 +149,7 @@ async def forward_authentication(
|
||||
return Response(status_code=204, headers=remote_headers)
|
||||
except HTTPException as e:
|
||||
# Let global handler clear cookie; still return HTML surface instead of JSON
|
||||
html = frontend.file("restricted/forward", "index.html").read_bytes()
|
||||
html = frontend.file("int", "restricted", "index.html").read_bytes()
|
||||
status = e.status_code
|
||||
# If 401 we still want cookie cleared; rely on handler by raising again not feasible (we need HTML)
|
||||
if status == 401:
|
||||
|
||||
@@ -55,9 +55,18 @@ app.mount("/auth/admin/", admin.app)
|
||||
app.mount("/auth/api/", api.app)
|
||||
app.mount("/auth/ws/", ws.app)
|
||||
app.mount(
|
||||
"/auth/assets/", StaticFiles(directory=frontend.file("assets")), name="assets"
|
||||
"/auth/assets/",
|
||||
StaticFiles(directory=frontend.file("auth", "assets")),
|
||||
name="assets",
|
||||
)
|
||||
|
||||
|
||||
@app.get("/auth/restricted")
|
||||
async def restricted_view():
|
||||
"""Serve the restricted/authentication UI for iframe embedding."""
|
||||
return FileResponse(frontend.file("auth", "restricted", "index.html"))
|
||||
|
||||
|
||||
# Navigable URLs are defined here. We support both / and /auth/ as the base path
|
||||
# / is used on a dedicated auth site, /auth/ on app domains with auth
|
||||
|
||||
@@ -74,8 +83,8 @@ async def frontapp(request: Request, response: Response, auth=AUTH_COOKIE):
|
||||
cur_host = hostutil.normalize_host(request.headers.get("host"))
|
||||
cfg_normalized = hostutil.normalize_host(cfg_host)
|
||||
if cur_host and cfg_normalized and cur_host != cfg_normalized:
|
||||
return FileResponse(frontend.file("host", "index.html"))
|
||||
return FileResponse(frontend.file("index.html"))
|
||||
return FileResponse(frontend.file("int", "host", "index.html"))
|
||||
return FileResponse(frontend.file("auth", "index.html"))
|
||||
|
||||
|
||||
@app.get("/admin", include_in_schema=False)
|
||||
@@ -96,4 +105,4 @@ async def reset_link(reset: str):
|
||||
"""Serve the reset app directly with an injected reset token."""
|
||||
if not passphrase.is_well_formed(reset):
|
||||
raise HTTPException(status_code=404)
|
||||
return FileResponse(frontend.file("reset", "index.html"))
|
||||
return FileResponse(frontend.file("int", "reset", "index.html"))
|
||||
|
||||
@@ -7,8 +7,7 @@ from passkey.util import useragent
|
||||
from .. import aaguid
|
||||
from ..authsession import session_key
|
||||
from ..globals import db
|
||||
from ..util import hostutil, permutil
|
||||
from ..util.tokens import encode_session_key
|
||||
from . import hostutil, permutil, tokens
|
||||
|
||||
|
||||
def _format_datetime(dt):
|
||||
@@ -108,7 +107,7 @@ async def format_user_info(
|
||||
for entry in session_records:
|
||||
sessions_payload.append(
|
||||
{
|
||||
"id": encode_session_key(entry.key),
|
||||
"id": tokens.encode_session_key(entry.key),
|
||||
"host": entry.host,
|
||||
"ip": entry.ip,
|
||||
"user_agent": useragent.compact_user_agent(entry.user_agent),
|
||||
|
||||
Reference in New Issue
Block a user