Moved the restricted-api iframe src to /auth/api/restricted and removed the endpoint of the other restricted app.
This commit is contained in:
@@ -41,7 +41,6 @@ Notes:
|
|||||||
| GET | `/auth/` | `/` | Main authentication SPA (non-auth hosts show an account summary view) |
|
| GET | `/auth/` | `/` | Main authentication SPA (non-auth hosts show an account summary view) |
|
||||||
| GET | `/auth/admin/` | `/admin/` | Admin SPA root |
|
| GET | `/auth/admin/` | `/admin/` | Admin SPA root |
|
||||||
| GET | `/auth/{reset_token}` | `/{reset_token}` | Reset / device addition SPA (token validated) |
|
| GET | `/auth/{reset_token}` | `/{reset_token}` | Reset / device addition SPA (token validated) |
|
||||||
| GET | `/auth/restricted` | `/restricted` | Restricted / permission denied SPA |
|
|
||||||
|
|
||||||
## Core API (Unrestricted – available on all hosts)
|
## Core API (Unrestricted – available on all hosts)
|
||||||
|
|
||||||
@@ -49,6 +48,8 @@ Always under `/auth/api/` (even on auth host):
|
|||||||
|
|
||||||
| Method | Path | Description |
|
| Method | Path | Description |
|
||||||
|--------|------|-------------|
|
|--------|------|-------------|
|
||||||
|
| GET | `/auth/api/restricted` | Authentication UI for iframe embedding (supports `?mode=login` or `?mode=reauth`) |
|
||||||
|
|--------|------|-------------|
|
||||||
| POST | `/auth/api/validate` | Validate & (conditionally) renew session |
|
| POST | `/auth/api/validate` | Validate & (conditionally) renew session |
|
||||||
| GET | `/auth/api/forward` | Auth proxy endpoint for reverse proxies (204 or 4xx) |
|
| GET | `/auth/api/forward` | Auth proxy endpoint for reverse proxies (204 or 4xx) |
|
||||||
| POST | `/auth/api/set-session` | Set cookie from Bearer token |
|
| POST | `/auth/api/set-session` | Set cookie from Bearer token |
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
iframe.title = 'Authentication';
|
iframe.title = 'Authentication';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
}
|
}
|
||||||
iframe.src = '/auth/restricted-api/?mode=login';
|
iframe.src = '/auth/api/restricted?mode=login';
|
||||||
showStatus('Login mode loaded - for users who are not authenticated', 'info');
|
showStatus('Login mode loaded - for users who are not authenticated', 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
iframe.title = 'Authentication';
|
iframe.title = 'Authentication';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
}
|
}
|
||||||
iframe.src = '/auth/restricted-api/?mode=reauth';
|
iframe.src = '/auth/api/restricted?mode=reauth';
|
||||||
showStatus('Reauth mode loaded - for additional verification of authenticated users', 'info');
|
showStatus('Reauth mode loaded - for additional verification of authenticated users', 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@
|
|||||||
iframe = document.createElement('iframe');
|
iframe = document.createElement('iframe');
|
||||||
iframe.id = 'auth-iframe';
|
iframe.id = 'auth-iframe';
|
||||||
iframe.title = 'Authentication';
|
iframe.title = 'Authentication';
|
||||||
iframe.src = '/auth/restricted-api';
|
iframe.src = '/auth/api/restricted';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
iframeInitialized = true;
|
iframeInitialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function showAuthIframe() {
|
|||||||
authIframe = document.createElement('iframe')
|
authIframe = document.createElement('iframe')
|
||||||
authIframe.id = 'auth-iframe'
|
authIframe.id = 'auth-iframe'
|
||||||
authIframe.title = 'Authentication'
|
authIframe.title = 'Authentication'
|
||||||
authIframe.src = '/auth/restricted-api/?mode=login'
|
authIframe.src = '/auth/api/restricted?mode=login'
|
||||||
document.body.appendChild(authIframe)
|
document.body.appendChild(authIframe)
|
||||||
loadingMessage.value = 'Authentication required...'
|
loadingMessage.value = 'Authentication required...'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ function showAuthIframe() {
|
|||||||
authIframe = document.createElement('iframe')
|
authIframe = document.createElement('iframe')
|
||||||
authIframe.id = 'auth-iframe'
|
authIframe.id = 'auth-iframe'
|
||||||
authIframe.title = 'Authentication'
|
authIframe.title = 'Authentication'
|
||||||
authIframe.src = '/auth/restricted-api/?mode=login'
|
authIframe.src = '/auth/api/restricted?mode=login'
|
||||||
document.body.appendChild(authIframe)
|
document.body.appendChild(authIframe)
|
||||||
loadingMessage.value = 'Authentication required...'
|
loadingMessage.value = 'Authentication required...'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from fastapi import (
|
|||||||
Request,
|
Request,
|
||||||
Response,
|
Response,
|
||||||
)
|
)
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import FileResponse, JSONResponse
|
||||||
from fastapi.security import HTTPBearer
|
from fastapi.security import HTTPBearer
|
||||||
|
|
||||||
from passkey.util import frontend
|
from passkey.util import frontend
|
||||||
@@ -36,6 +36,12 @@ app = FastAPI()
|
|||||||
app.mount("/user", user.app)
|
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)
|
@app.exception_handler(HTTPException)
|
||||||
async def http_exception_handler(_request: Request, exc: HTTPException):
|
async def http_exception_handler(_request: Request, exc: HTTPException):
|
||||||
"""Ensure auth cookie is cleared on 401 responses (JSON responses only)."""
|
"""Ensure auth cookie is cleared on 401 responses (JSON responses only)."""
|
||||||
|
|||||||
@@ -89,16 +89,6 @@ async def admin_root(request: Request, auth=AUTH_COOKIE):
|
|||||||
return await admin.adminapp(request, auth) # Delegated to admin app
|
return await admin.adminapp(request, auth) # Delegated to admin app
|
||||||
|
|
||||||
|
|
||||||
@app.get("/auth/restricted")
|
|
||||||
async def restricted_view():
|
|
||||||
return FileResponse(frontend.file("restricted", "index.html"))
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/auth/restricted-api")
|
|
||||||
async def restricted_api_view():
|
|
||||||
return FileResponse(frontend.file("restricted-api", "index.html"))
|
|
||||||
|
|
||||||
|
|
||||||
# Note: this catch-all handler must be the last route defined
|
# Note: this catch-all handler must be the last route defined
|
||||||
@app.get("/{reset}")
|
@app.get("/{reset}")
|
||||||
@app.get("/auth/{reset}")
|
@app.get("/auth/{reset}")
|
||||||
|
|||||||
Reference in New Issue
Block a user