Commit Graph
519 Commits
Author SHA1 Message Date
LeoVasanko b901a34615 Docs + e2e: single origins table, explicit-origins semantics
MultiSite.md/API.md/README: one allowed-origins list per domain where
out-of-domain entries are related origins; empty list allows nothing;
plain '*' rejected; new domains and legacy conversions seed '*.{rp-id}'.
E2E multidomain spec: new payload shape; restores return to the seeded
wildcard state.
2026-09-07 14:47:50 +00:00
LeoVasanko a6138d97f9 Single origins table per domain; explicit origins semantics
DomainConfig.related is gone: origins holds both in-domain sign-in sites
and related origins, classified by whether the entry lies within the
rp-id. Misfiling is impossible by construction, so validation/sanitize
lose their reclassification paths.

Origins are now always explicit: an empty table allows nothing (a
related-only domain is a valid configuration). Plain '*' is rejected —
wildcards must be under the rp-id ('*.{rp-id}'). New databases, added
domains and legacy conversions seed '*.{rp-id}' (legacy empty origins
meant allow-all). Passkey's implicit allow-all default is gone; the
admin API takes a single origins map and the lockout guard refuses
emptying the table on the domain in use.
2026-09-07 14:40:37 +00:00
LeoVasanko 93742ecdcf Trim: top-level Passkey import in domains.py
The import cycle that forced the lazy import no longer exists.
2026-09-07 13:36:51 +00:00
LeoVasanko 49e37f9afe Docs: rewrite MultiSite.md from the webadmin perspective; refresh oidc.md
MultiSite.md now describes the shipped feature for administrators —
managing domains in the admin panel, sign-in sites, the auth host,
related origins, cross-domain sign-in, OIDC discovery, CLI and 1.x
upgrade notes — instead of the internal design narrative. oidc.md:
realms -> domains, instance-global provider, current auth-code shapes.
2026-09-07 13:33:48 +00:00
LeoVasanko 0d1d18e8a7 Frontend: domain dialog fixes and dead-code removal
- Empty-origins default shows as a '*' placeholder row that is not
  persisted unless edited (open+save no longer tightens any-scheme to
  https-only)
- Foreign wildcards are flagged invalid instead of being classified as
  related origins; over-cap related list disables Save
- Single-label rp-ids accepted (matching backend validate_rp_id)
- Auth-host mark follows row edits; row menu state resets on dialog close
- rp-id/origin keys lowercased for classification and submit
- settings cache: stale in-flight responses no longer overwrite a forced
  refresh
- Remove the dead oidc-edit dialog path and other unused code; fix stale
  comments (realm→domain, '*' semantics, per-domain discovery URLs)
2026-09-07 13:24:19 +00:00
LeoVasanko 3ff41ca354 Review fixes: validation hardening, dead code, stale comments
- validate_config: reject multiple auth-host marks per domain;
  sanitize_config clears extras (first wins) and coerces junk entry
  values to presence-only
- origin_key: lowercase keys, strip trailing dots (bare hosts/wildcards)
- Passkey._allowlisted: tolerate trailing-dot wildcard bases
- wschat: stamp remote-flow sessions with the session host's domain,
  not the approver's
- auth_host redirects: keep the port (redirect to the configured auth
  host instead of the normalized, port-less current host)
- update_domain: required fields (wholesale replace) — no silent wipes
- admin: fix pre-existing lockout-guard order in org permission removal;
  permission PATCH keeps domain restriction when omitted; 400 instead of
  500 on unknown permission UUIDs
- Drop dead code: db.update_config/set_session_host/delete_reset_token,
  Session.metadata, oidjwt.clear_key, background aliases,
  avatar.current_avatar_url/media_root, wsutil.require_pow
- Prune stale/duplicated comments and docstrings
2026-09-07 07:53:27 +00:00
LeoVasanko 2039c47e46 Tests: align with instance-global OIDC and per-domain auth hosts
- '*' origin is wildcard shorthand (https-only outside localhost)
- related origins may fall inside another domain's rp-id; the listing
  wins dispatch, an exact rp-id always wins
- shared auth hosts resolve best-suffix; no cross-domain fallback
- OIDC codes are host-independent; log censoring path is oidc.key
- legacy wildcards convert as-is; legacy OIDC carries over as-is
2026-09-07 06:33:54 +00:00
LeoVasanko af6d7e3a3f Instance-global OIDC provider; per-domain auth hosts with shared-host resolution
- DB.oidc is a single OIDC (one key, one client set); hosts are issuer
  aliases. OIDCCode drops its rp_id field; client CRUD is not keyed by
  domain.
- No cross-domain auth-host fallback: a domain without its own auth host
  uses its own hosts; several domains may share one auth host (nested
  rp-ids) with deterministic best-suffix resolution.
- '*' origin shorthand expands to '*.{rp-id}'; legacy wildcards convert
  as-is; related origins may point at/inside another domain's rp-id.
- Admin UI and docs updated to match.
2026-09-07 06:10:08 +00:00
LeoVasanko 00560a05c1 Admin UI: compact JSON for the proposed well-known webauthn document 2026-09-07 03:16:18 +00:00
LeoVasanko 7ff8869e1d CLI: positional rp-id/rp-name; init adds domains to an existing database
- 'paskia init [rp-id] [rp-name]' and 'paskia migrate [rp-id]' are now
  positional; comma separation and the --rp-id/--rp-name flags are gone.
- With an existing paskia.kantadb, init adds the rp-id as a new domain
  (seeding its OIDC provider) or updates an existing domain's rp-name.
- Origin allow-list semantics clarified: the bare '*' entry allows
  anything within the rp-id domain on any scheme and port (also the
  empty-list default and its display in the admin UI, replacing the
  synthetic '*.rp-id' row); '*.x' wildcards are https-only; exact entries
  match scheme, host and port. Legacy '*.rp-id' wildcards migrate to '*'
  to preserve their any-scheme meaning.
2026-09-07 03:07:38 +00:00
LeoVasanko 476ce996ad Simplify paskia init to rp-id/rp-name only
Only rp-id and rp-name are essential bootstrap-time configuration;
origins and auth hosts are set up afterwards via the admin interface.
Removes --origin/--auth-host from init and from devserver, and the
now-unused hostutil.validate_auth_host.
2026-09-07 02:17:22 +00:00
LeoVasanko d767012d80 CLI help: drop remaining 'default domain' wording 2026-09-07 02:07:05 +00:00
LeoVasanko f2e6f5784e Rename realms to domains; object-keyed origins/related config format
Finish the realm→domain terminology removal across source, tests, e2e
and docs. The stored config drops all lists: Config.domains is keyed by
rp-id, DomainConfig.origins/related are objects keyed by host (https://
omitted), values True or OriginEntry(auth_host=True). The default/primary
domain concept is gone; ordering is display-time. Tests and e2e updated
to the new API shapes (not run). Database re-migrated from the legacy
backup into the new format.
2026-09-07 02:05:12 +00:00
LeoVasanko 80d55679fb Frontend: domain terminology, object-keyed origins, 🔑 auth host in table, display-time ordering 2026-09-07 01:31:14 +00:00
LeoVasanko 7a0737f867 Domains: object-keyed config format, drop default domain, rename realm→domain throughout backend 2026-09-07 01:25:29 +00:00
LeoVasanko dcfb497cf2 Wildcard origins + auth host configured per origin row (⋮ menu, 🔑 indicator) 2026-09-07 00:53:33 +00:00
LeoVasanko 7a9953f703 Admin UI: single origins list with automatic in-domain/ROR split + well-known check 2026-09-07 00:27:58 +00:00
LeoVasanko 7f1688e1f5 Admin UI: prefill new sign-in site with the admin's current origin on the current domain 2026-09-07 00:12:49 +00:00
LeoVasanko 38d994f312 Admin UI: rename Realms to Domains, list allowed origins per domain 2026-09-07 00:08:07 +00:00
LeoVasanko b6a1b2e4a8 Admin UI: correct auth-host help — it moves the account/admin UI, sign-in works on every site 2026-09-06 23:34:25 +00:00
LeoVasanko f5bd0a469c Best-effort serve for bad stored config + admin self-lockout guards
Serving never refuses to start because of stored realm config: the
registry build sanitizes best-effort and warns — misfiled origin entries
are reclassified (a cross-domain origins entry is served as a related
origin) or dropped, collisions resolve first-come-wins, over-cap related
lists truncate, unsalvageable realms are skipped. Fixing the stored
config stays the admin interface's job, and it stays reachable on any
working realm. Only a config with no servable realm at all is fatal.

Admin realm writes stay strict and gain self-lockout guards: an update
that would leave the admin's current host unable to run ceremonies for
the realm they are on is refused (unless an auth host takes over
ceremonies), and deleting the realm currently in use is refused.
2026-09-06 22:52:00 +00:00
LeoVasanko b9e6f4bc27 Separate related domains (ROR) from the in-domain sign-in allow-list
RealmConfig.origins is again purely an allow-list of sign-in sites
within the realm's domain (unset = rp-id and all subdomains), restoring
the restriction semantics the realm rework had silently turned into an
always-open subtree. Cross-domain ROR origins move to their own
RealmConfig.related_origins field — always additive, capped, validated
to be outside the rp-id domain, and the sole source of the
/.well-known/webauthn document.

Admin API POST/PATCH accept related_origins; misfiled entries are
rejected (cross-domain in origins, in-domain in related_origins).

Admin UI: the realm dialog edits the two lists separately with
end-user-oriented explanations (allowed sign-in sites vs. related
domains + the well-known note); the Realms section intro explains the
multi-domain model, and the table shows sign-in site and related domain
counts.
2026-09-06 22:29:12 +00:00
LeoVasanko fefd54f02a CLI: explicit 'paskia migrate' subcommand for legacy conversion
Serve never converts databases: with no paskia.kantadb it points at
'paskia init', or at 'paskia migrate' when legacy *.paskiadb candidates
exist. migrate converts a lone candidate, or the one named by --rp-id
when several exist; the rest stay in place. devserver fails fast with
the same hint. gitignore covers paskia.kantadb and *.converted-bak.
2026-09-06 22:11:17 +00:00
LeoVasanko 9b10663c10 MultiSite.md: describe only current state and design rationale
Drop all before/after contrasts, deferred ideas, and possible follow-ups
(Identity layer, per-realm remote-auth policy flag, same-device redirect
variant, legacy-module deletion note).
2026-09-06 15:55:55 +00:00
LeoVasanko 2baebc4072 Docs: multi-realm current state
README quick start and configuration updated for init/serve split and
paskia.kantadb; API.md server-config endpoints replaced with admin realm
CRUD and the well-known webauthn endpoint; proxy guides point at the
realm auth-host setting; oidc.md documents per-realm issuers; MultiSite.md
rewritten from the implementation plan into documentation of the shipped
mechanics, policy model, and design rationale.
2026-09-06 15:13:10 +00:00
LeoVasanko 8ccc257f44 E2E: two-realm setup, host dispatch, related origins, cross-realm remote login
- global-setup bootstraps via one-shot 'paskia init --rp-id
  localhost,test.localhost' in the test-data directory (which doubles as
  the server cwd, dropping the removed PASKIA_DB), captures the reset
  token from init output (stdout+stderr), then spawns plain serve.
- New 50-multirealm spec: per-host settings dispatch, 421 for unknown
  hosts, /.well-known/webauthn 404 until a related origin is added via
  the admin realm API (and removed again), and a full cross-realm remote
  login: requester on test.localhost, permit on localhost with a fresh
  virtual-authenticator passkey, session validated on test.localhost.
  Asserts the profile enrollment prompt and realm badge render.
- New fixtures/remote-auth.ts drives the remote-auth WS protocol in
  browser context, including the PBKDF2 PoW.
2026-09-06 15:06:20 +00:00
LeoVasanko e979dd6312 Devserver and proxy configs for multi-realm
- devserver bootstraps via one-shot 'paskia init' when no database
  exists (multi --rp-id, --rp-name/--auth-host/--origin apply to the
  default realm), then runs plain 'paskia' serve which reads all realm
  configuration from the database; legacy *.paskiadb is adopted by
  serve without init.
- Caddy origins iterate all bootstrap rp-ids.
- vite.config.js accepts a comma-separated PASKIA_AUTH_HOST list and
  proxies /.well-known/webauthn to the backend so ROR works in dev.
- caddy/auth/setup forwards /.well-known/openid-configuration and
  /.well-known/webauthn to paskia (they must not be swallowed by a
  static /.well-known/* file handler); Caddyfile.dev updated to match
  the generated dev config.
2026-09-06 14:49:27 +00:00
LeoVasanko 8e7acd6b9e Frontend: realm admin UI, passkey realm badges, cross-realm notices
- Admin: replace Server Options dialog with per-realm management —
  realms table on the overview, add/edit/delete realm dialog backed by
  /auth/api/admin/realms/. Origins may be any well-formed origin;
  non-subdomain ones are related origins (ROR, max 5) and the dialog
  points at the .well-known/webauthn URL that must list them.
  Connectivity checks compare against the edited realm's rp-id and
  degrade to warnings instead of blocking saves.
- Host mode (limited profile) now keys off own_auth_host so realms
  sharing another realm's auth host serve the full profile locally.
- Credential list shows a realm badge on passkeys registered for a
  different rp-id than the current realm.
- Profile shows an enrollment prompt when the user has no passkey for
  the current realm (e.g. after a cross-realm remote login).
- Remote auth permit shows the requesting realm when it differs from
  the approver's own.
- settings cache can be force-refreshed after realm changes.
2026-09-06 04:50:35 +00:00
LeoVasanko cdabc5d9e6 Realm machinery tests: resolution, validation, dispatch, code binding, conversion
- Registry resolve order (exact rp-id, auth host, related origin,
  longest suffix), port/trailing-dot normalization, unknown hosts.
- Cross-realm validate_config: related-origin cap, auth-host/related
  collisions, related-inside-other-realm, auth-host vs rp-id.
- ASGI dispatch: HTTP 421, realm in scope state, contextvar scoping and
  reset, WS pre-accept close and cross-realm effective-auth-host rule.
- Auth codes bound to issuing realm (set-session and OIDC token).
- Legacy conversion stamps credentials/sessions/OIDC with the rp-id.
- OIDC key censoring in transaction logs; bootstrap default-realm caveat.
2026-09-06 04:33:08 +00:00
LeoVasanko 33d3b88941 Test suite for the realm architecture
- conftest: bootstrap seeds a localhost realm Config; realm_registry
  fixture builds the runtime registry; avatar storage redirected to a
  per-test tmp dir; credentials/sessions stamped with the test realm.
- test_cli rewritten for the init/serve split, incl. legacy adoption.
- TestServerConfig replaced by TestRealms covering the realm CRUD API,
  cross-realm validation, delete guards and effective-auth-host fallback.
- Avatar/OIDC tests updated for per-realm providers and realm-derived
  URLs; obsolete PASKIA_DB path tests removed.
2026-09-06 04:28:35 +00:00
LeoVasanko f44bcc9dea Realm dispatch, per-realm OIDC, realm-scoped credentials and admin realm API
- DispatchMiddleware (outermost app middleware) resolves Host to a realm:
  HTTP 421 for unknown hosts, WS closed pre-accept (1008); cross-realm WS
  only via the origin realm's effective auth host. Current realm exposed
  via request.state.realm and the current_realm() contextvar.
- Credentials and sessions are scoped by realm rp_id: authentication only
  matches credentials of the dispatched realm; sessions record rp_id.
- Auth codes (OIDC and cookie exchange) are stamped with the issuing
  realm and verified at redemption; remote-auth permits mint the exchange
  code for the *requesting* device's realm.
- OIDC provider state (clients, signing keys) is per realm; token,
  userinfo, keys and backchannel-logout endpoints use the dispatched
  realm; refresh re-stamps the session issuer.
- /.well-known/webauthn serves the realm's related origins (ROR).
- Admin /server-config replaced by /realms CRUD (validated cross-realm,
  registry rebuilt on change); permission domains may reference any
  realm's hosts or clients; /settings reports the realm's own vs
  effective auth host.
- paskia.globals and the runtime-backed hostutil helpers are gone.
2026-09-06 04:11:22 +00:00
LeoVasanko 4591a023dd Clean-slate storage: realms Config, Credential.rp_id, Session rp_id/issuer, per-realm OIDC
- Config is now a realm list (first = default); DB.oidc keyed by rp-id
- Database at fixed paskia.kantadb; user files under paskia.data/users/
- Legacy <rp-id>.paskiadb reader/converter in db/legacy.py (to be deleted eventually)
- paskia init / paskia serve CLI split; serve adopts a lone legacy database
- Realm registry (paskia/realms.py) with cross-realm validation
- Per-realm OIDC keys in oidjwt; backchannel logout uses Session.rp_id/issuer
- Schema migrations discarded; on-disk legacy format assumed current
2026-09-06 03:50:06 +00:00
LeoVasanko 2da1ce777a Multi-site plan v4: combined paskia.kantadb, bootstrap-only CLI, runtime realm management 2026-09-06 03:19:42 +00:00
LeoVasanko 383c9f472e Add public access mode (public=1) to forward auth
/auth/api/forward?public=1 passes requests through with a Remote-Public
header (anonymous/forbidden/authenticated) instead of 401/403, so routes
can allow anonymous visitors while still identifying logged-in users.
Reauth (max_age) still requires the auth flow. Documented in Headers.md,
api/forward.md, Integration.md and all proxy guides.
2026-09-05 16:06:32 +00:00
LeoVasanko 8c2809a879 Update fastapi-vue-setup, make use of its access logging facility. 2026-09-05 14:36:25 +00:00
LeoVasanko 3912b5473e Fix Caddyfile indentation 2026-08-15 05:54:28 +00:00
LeoVasanko 223429d51c Add renew=0 query arg on validate, useful when only a permission check is required. v1.5.6 2026-08-11 01:46:56 +00:00
LeoVasanko 2456730f70 Check max-age only after checking permissions: if neither is passing, we want a 403 error; simply authenticating again won't fix it so don't bother reauth flow. After forbidden flow e.g. account change we are already good with max-age too. v1.5.5 2026-08-11 00:56:01 +00:00
LeoVasanko f74bf3ebe6 Require Python 3.14, ruff formatting for simpler typing. 2026-08-11 00:46:45 +00:00
LeoVasanko 79074dd4f1 OR semantics in perm query arg, strict parsing, segment-aware wildcards
perm=a|b+c now means (a or b) and c; repeated perm args remain ANDed.
Out-of-spec values (empty alternatives, chars outside the scope charset,
stray %2B) are rejected with 400 instead of being silently misparsed;
extra spaces between groups are tolerated. Forward endpoint 400/500
details name /auth/api/forward as origin without echoing query args.
Wildcards are now filename-like: * stays within a :- or /-separated
segment, ** spans segments, partial segments allowed. Slash added to
allowed scope characters for path-based permissions.
2026-08-11 00:44:58 +00:00
LeoVasanko 00ef0ae2e7 Update API and proxy docs 2026-08-10 21:35:46 +00:00
LeoVasanko 6f5287e070 Avoid clearing session.user_agent if a validation request lack this header. Backend-initiated session validations may not have the data. 2026-08-10 14:09:42 +00:00
LeoVasanko 051e1bbb41 Replace paskia.db.logging with kanta's built-in logging (kanta 0.7.0)
The vendored db/logging module duplicated what kanta now provides:
diff formatting, UUID-to-label resolution via logfmt callbacks, unsafe
character filtering and value truncation. Censoring of oidc.key material
moves into the format_log_uuid logfmt callback in db.lifecycle, taking
care to hide only the value, not the 'key' path component itself.
v1.5.4
2026-08-09 23:25:16 +00:00
LeoVasanko 4b156b712c Proper handling of auth site runtime change done via web interface, making the change immediately effective. Kept in origins list that is still also visible on the same dialog, where it can be removed if needed. 2026-08-09 23:00:22 +00:00
LeoVasanko df8a7c0026 Cleanup of admin user panel where incorrect toast messages were issued after changes. 2026-08-09 21:45:23 +00:00
LeoVasanko 9b28250391 Upgrade to kanta 0.4.0:
- Make use of its new features and cleanup our interfacing and init/shutdown processes and migrations
- Clean up circular deps, simplify app init
- Add specific pytest for CLI main to cover the changes
v1.5.3
2026-06-13 21:59:18 +00:00
LeoVasanko b9aec6bb58 Remove built-in database, replace with kanta package. No disk format changes. v1.5.2 2026-06-12 19:39:30 +00:00
LeoVasanko c79cb497ee Fix profile image path on OIDC. v1.5.1 2026-05-22 02:45:12 +00:00
LeoVasanko 9f50c8c20d Missing file v1.5.0 2026-05-22 01:40:53 +00:00
LeoVasanko 816c7a681e Update E2E tests for new database folder. 2026-05-22 01:40:09 +00:00