Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GrampsWebApiDb/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GrampsWebApiDb/README.md
58 changes: 58 additions & 0 deletions GrampsWebApiDb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
GrampsWebApiDb is a Gramps database backend that uses a Gramps Web API
server (e.g. gramps-connect or Gramps Web) as a live database, mirrored
locally in SQLite for speed. Reads are served from the local mirror, which
is kept current via the server's transaction-history feed -- both at load
time and on an ongoing poll while the tree stays open, so a change made
from another client (the web app, another desktop instance) shows up here
without closing and reopening the tree; local edits are pushed back to the
server as they're committed. Every already-open Gramps view (People,
Families, ...) refreshes itself automatically as synced changes land, the
same as it would for a local edit -- see `grampswebapidb.py`'s module
docstring for how.

## Credentials

The addon takes a single credential, via the `GRAMPS_WEB_API_KEY`
environment variable, shaped `<REFRESH_TOKEN>*<BASE64URL(URL)>`. There is
deliberately no login dialog and no per-tree settings.ini. Mint one once
via username/password, either from the command line with the standalone
`gramps-api-client` package (not yet published; pip-installable from
its own repo, e.g. `pip install -e path/to/gramps-api-client`):

```bash
export GRAMPS_WEB_API_KEY=$(gramps-api-client generate-key --url https://your-server/api --username youruser)
```

or from Python, using either that package's `Client.mint_api_key(url,
username, password)` or this addon's own vendored copy,
`WebApiHandler.mint_api_key(url, username, password)` (see
`webapi_client.py`) — same method, same result, no addon-specific
dependency either way.

**Security tradeoff:** the token embedded in `GRAMPS_WEB_API_KEY` is a
standard JWT *refresh* token obtained from the server's normal `/token/`
login endpoint — the same endpoint and flow the official web client uses,
not an undocumented or exploited access path. gramps-web-api leaves refresh
tokens non-expiring by default, so this key is a long-lived, general-purpose
credential carrying the full permissions of the account that minted it. It
is *not* the same as a real scoped, independently revocable personal access
token (gramps-web-api has that machinery, but it isn't generally wired into
request auth yet). Practically, that means:

* A leaked `GRAMPS_WEB_API_KEY` is as damaging as a leaked password — it
grants full account access until the underlying password is changed.
There is no "revoke this key" action independent of that.
* Treat it accordingly: don't commit it, don't log it, and store it the
same way you'd store a password.

This is a documented engineering tradeoff, made because the properly-scoped
alternative isn't available server-side today — not a vulnerability in
gramps-web-api or a loophole being exploited.

## See also

* `grampswebapidb.py` for the sync/write-through design (module docstring).
* `webapi_client.py` for the token fetch/refresh implementation. This is a
hand-synced vendored copy (see its own docstring) -- the canonical,
standalone source is the `gramps-api-client` package, which also
has the `generate-key` CLI referenced above.
37 changes: 37 additions & 0 deletions GrampsWebApiDb/grampswebapidb.gpr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2026 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
register(
DATABASE,
id="grampswebapidb",
status=UNSTABLE,
name=_("GrampsWebApiDb"),
name_accell=_("Gramps _Web API Database"),
description=_(
"Use a Gramps Web API server (e.g. gramps-connect or Gramps Web) "
"as a live database, mirrored locally for speed."
),
version="0.1.0",
gramps_target_version="6.0",
fname="grampswebapidb.py",
databaseclass="WebApiDB",
authors=["Doug Blank"],
authors_email=["doug.blank@gmail.com"],
help_url="Addon:GrampsWebApiDb",
)
Loading