Repository navigation
harvest-invoicer: optional OIDC login and waitress for server deployments - #189
Merged
Merged
Conversation
…ents The editor has no authentication, so it could only run on loopback. With an issuer configured, `serve` now requires an OIDC login (Authlib: discovery, S256 PKCE, state and nonce, pinned iss/aud, an RS256/PS256/ES256/EdDSA allow-list) and only admits allow-listed subjects or verified emails. It fails closed on an empty allow-list, a missing session secret or a missing public URL. Sessions have an absolute lifetime (12 h by default) and logout is a CSRF-guarded POST that also ends the provider session. ProxyFix makes it work behind a reverse proxy, and redirect URIs come only from the configured public URL. In OIDC mode the app is served by waitress, a single-process multithreaded server with request limits and a clean SIGTERM shutdown; `--server` forces either one. Without an issuer nothing changes: local `serve`, `--demo` and `generate` behave as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
harvest-invoicer servehas no authentication, so the README tells people never to expose it, which rules out running it on a server. This adds an optional OIDC login, plus a production server for that mode. Without an issuer, nothing changes: localserve(loopback, browser),--demoandgeneratebehave as before.OIDC login (opt-in: enabled when
--oidc-issueris set)issuermust match the configured one; S256 PKCE; state and nonce;iss/audpinned explicitly, since Authlib's default would accept a foreignaudwhenazpmatches.email_verified. If the ID token lacks either claim (Zitadel's default), they are read fromuserinfo, whosesubmust match the ID token's.--oidc-allow-any-user), without a session secret of at least 32 characters, or without--public-url. Redirect and post-logout URIs come only from the public URL, never from request headers.--session-lifetime, 12 h by default);HttpOnly,SameSite=Lax, andSecurebehind https;/login?next=…(same-origin paths only);HX-Redirect;end_session_endpoint).--trusted-proxies, 1 by default with OIDC), and the public host is accepted by the existing CSRF guard./quit: disabled under OIDC.*_FILEor the environment, never logged; log lines escape provider-supplied text.Server
In OIDC mode
serveruns on waitress (--server auto|werkzeug|waitress,--threads):channel_timeout=60,connection_limit=100, header and body size caps.X-Forwarded-*.Tests
nix build.alg: none, HS256-only provider, foreignaud, expired token, a token response withoutid_token, bad or replayedstate,userinfosubmismatch.Checks
nix fmtis clean (ruff ALL, mypy strict) andnix flake checkpasses. Dependencies added:authlib,requestsandwaitress, in bothpyproject.toml/uv.lockand the Nix package.The README gains a Server deployment (OIDC) section listing every option and environment variable, with an example, and its Security section is updated.