Compare commits

..
3 Commits
5 changed files with 22 additions and 11 deletions
+11 -2
View File
@@ -25,14 +25,22 @@ def create_banner():
"""
def create_startup_box(*, folder, url, unix=None, dev=False, paskia_url=None):
def create_startup_box(
*, folder, url, unix=None, dev=False, paskia_url=None, public=False
):
"""Create a framed startup box with server information."""
title = f"Cista {cista.__version__}"
listen = unix if unix else url
location = f"{folder} @ {listen}"
lines = [title, location]
# Auth line: Paskia <url> or Password, with optional Public suffix
if paskia_url:
lines.append(f"Paskia: {paskia_url}")
auth_line = f"Auth: Paskia {paskia_url}"
else:
auth_line = "Auth: Password"
if public:
auth_line += ", Public"
lines.append(auth_line)
if dev:
lines.append("dev mode")
@@ -157,6 +165,7 @@ def _main():
unix=opts.get("unix"),
dev=dev,
paskia_url=PASKIA_BACKEND_URL or None,
public=config.config.public,
)
sys.stderr.write(startup_box)
# Run the server
+6 -4
View File
@@ -166,10 +166,12 @@ def subscribe(uuid, ws):
@bp.get("config")
async def get_config(request):
await auth.verify(request, privileged=True)
return json({
"name": config.config.name,
"public": config.config.public,
})
return json(
{
"name": config.config.name,
"public": config.config.public,
}
)
@bp.put("config/public")
+2 -2
View File
@@ -269,7 +269,7 @@ async def verify(request, *, privileged=False):
raise Unauthorized(
f"Login required for {request.path}",
"cookie",
context={"auth": {"iframe": "/auth/restricted"}},
context={"auth": {"iframe": "/auth/restricted/"}},
quiet=True,
)
@@ -278,7 +278,7 @@ async def verify(request, *, privileged=False):
bp = Blueprint("auth", url_prefix="/auth")
@bp.get("/restricted")
@bp.get("/restricted/")
async def login_page(request):
"""Login page that works both standalone and in paskia iframe."""
s = session.get(request)
+2 -2
View File
@@ -157,8 +157,8 @@ const freeColor = computed(() => {
if (!s.disk) return '#6c6'
const freePct = s.free / s.disk
if (freePct > 0.25) return '#5b5'
if (freePct > 0.10) return '#db3'
return '#d44'
if (freePct > 0.10) return '#ff0'
return '#f00'
})
const PIE_RADIUS = 55
+1 -1
View File
@@ -115,7 +115,7 @@ const settingsMenu = (e: Event) => {
// Show login option only in public mode (non-public modes trigger auth automatically)
items.push({ label: '🔐 Login', onClick: async () => {
try {
await showAuthIframe('/auth/restricted#theme=light')
await showAuthIframe('/auth/restricted/#theme=light')
resumeWatching()
} catch (e) {
console.log('Login cancelled')