Add a read-only integration feed of walks and meals
GET /api/integration/events?since=<unix ms> returns one account's walk starts and meals that happened or changed since then, tombstones included, for other services on the same host. It is authenticated with a bearer token rather than a session and cannot write anything. Enabled with -integration-token-file (services.puppy-tracker .integration.tokenFile); -integration-user picks the account, and defaults to the only one.
This commit is contained in:
1 parent
b572371666
commit
15211e32b0
4 files changed
+220
-1
No files matched your search
+29
-1
@@ -63,6 +63,24 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
integration = {
|
||||
tokenFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
example = "/run/agenix/schema-puppy-token";
|
||||
description = ''
|
||||
File holding a bearer token (just the token) that unlocks the
|
||||
read-only GET /api/integration/events feed of walks and meals, used by
|
||||
other services on this host. When null the endpoint doesn't exist.
|
||||
'';
|
||||
};
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
description = "Email of the account the feed exposes. Empty means the only account.";
|
||||
};
|
||||
};
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = serverPkg;
|
||||
@@ -90,7 +108,17 @@ in
|
||||
"-addr ${cfg.address}:${toString cfg.port}"
|
||||
"-static ${cfg.staticPackage}/share/puppy-tracker"
|
||||
"-data /var/lib/puppy-tracker/puppy.db"
|
||||
] ++ lib.optional cfg.secureCookies "-secure-cookies");
|
||||
] ++ lib.optional cfg.secureCookies "-secure-cookies"
|
||||
# %d is the unit's credentials directory (see LoadCredential below).
|
||||
++ lib.optionals (cfg.integration.tokenFile != null) [
|
||||
"-integration-token-file %d/integration-token"
|
||||
"-integration-user ${lib.escapeShellArg cfg.integration.user}"
|
||||
]);
|
||||
|
||||
# DynamicUser can't own the secret, so systemd reads it as root and
|
||||
# hands the service a private copy.
|
||||
LoadCredential = lib.optional (cfg.integration.tokenFile != null)
|
||||
"integration-token:${toString cfg.integration.tokenFile}";
|
||||
|
||||
# Secrets (registration code, Web Push key) are read from env files kept
|
||||
# out of the store, exposed to the server as PUPPY_INVITE_CODE and
|
||||
|
||||
Reference in new issue
Block a user