Repository navigation
Sync v2: member list from the membership system (reader side) - #84
Merged
Merged
Conversation
…c v2) The member list now comes from the membership system's members.php (PPOE/admidio-addons) instead of the encrypted adm_names.php of the old, shut-down membership system. Settings in the new configuration file sync-secrets.php (release root, like constants.php): members_url (https only), members_token (Authorization: Bearer) and members_cafile, the only trust anchor (verify_peer and verify_peer_name on, no redirects, 20 s timeout, HTTP 200 required). The whole document is validated (a non-empty list of rows with exactly id, uuid, name, lo, paid; positive ids, UUIDs, no id or uuid twice); anything else fails closed as before. ppmembers stores the uuid. mb.php links profiles by user_uuid (validated as a UUID before it goes into the href); closed.php and new.php show the member id as text. membership_decrypt() is removed. deploy/: pgacc_members_url, pgacc_members_token, pgacc_members_cert (empty by default) fill shared/sync-secrets.php (root:pgacc 0640) and /etc/pgacc/members-tls.crt; pgacc-deploy links sync-secrets.php and refuses archives that contain one. Tests: the membership stub serves JSON and requires the token; new GetUsersTest cases for the refused fetches (certificate, name, cafile only, 500, redirect, 403), every kind of malformed list, the settings, the UUID check and the links; http-import checks the links on the member-fee page, the ledger and the voucher form (red against the old pages). The reference is re-recorded for the links and the stub path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mb.php was not in the phpunit coverage source, so the non-UUID branch of mb_member_link(), exercised by GetUsersTest, did not count and the changed-line coverage gate reported mb.php line 10 as uncovered. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Align the consumer side with the sync v2 cross-review: - One template task writes shared/sync-secrets.php from the inventory on every run (templates/sync-secrets.php.j2, root:pgacc 0640, no_log), replacing the "create if missing" shell task and the lineinfile loop. The template and the task are the same in the provider branch: the members_* keys while pgacc_members_url is set, the payments_* keys of the internal sync listener while it is on. - getusers_fetch(): fopen + stream_get_contents(4 MiB + 1), refused when larger or when the read timed out (same shape as accsync_fetch on the membership side). The stub gets a "stall" mode for the timeout test. - A sync-secrets.php that does not load (parse error, exception) fails closed with "Mitgliederliste nicht konfiguriert!" instead of a fatal error; only the class is logged. - The membership system's certificate is /etc/pgacc/admidio-addons-tls.crt (/etc/<app>/<peer>-tls.crt, as on the membership side). - The member list asserts move to their own task; the certificate tasks to their own section, so the two branches merge without conflicts in the playbook. - Docs: one "Sync v2" CHANGELOG entry and UPGRADING section, the certificate path convention, pgacc_timezone Europe/Vienna recommended. - tests/runtime/test-sync-secrets.php holds the payments_* and members_* test keys (same file in the provider branch). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The membership system's listener must serve members.php before pgacc_members_url is set; UPGRADING.md and deploy/README.md give a curl check that must print 200. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aders tests/sync-secrets-template.sh renders the real template with the template module (ansible-core of tests/playbook-settings.sh) for payments only, members only and both, and loads each file with sync_api_config() and getusers_config() where present. A broken template made every sync request 403, which the deploy smoke test accepts. Wired into the web-server CI job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PHP's stream timeout applies to each read, so a membership system that trickles the response could hold the request far longer. The fetch now reads the response itself under one deadline and fails closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both branches remove the old encrypted membership exchange: #83 the export (public/mbapi.php, membership_encrypt()), this branch the import (adm_names.php, membership_decrypt()). The conflicts keep neither helper, their mcrypt vectors and tests; the docs describe both directions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With both directions on sync v2 nothing reads $datakey: drop membership_cipher_params() and its mutants, $datakey of the test and reference constants, and the $datakey placeholder that the playbook wrote into a new constants.php. tests/sync-secrets-template.sh now requires both readers (sync_api_config() and getusers_config()). Docs say what is true with both PRs in: both directions on internal addresses, no public name or CA bundle, allow_url_fopen not needed by getusers.php. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As accsync.php of the add-ons: every Content-Length header, if there is one, must be 1-18 digits and equal the body length; otherwise the fetch fails closed on the same error path. Tests (red first): a 200 body cut short by an early close (no timeout), a longer body and a malformed value (stub modes short, long, badlength). Also for the mutation and changed-line gates of the new HTTP client: the four getusers mutants that still searched the old stream-wrapper code match the socket client; new mutants for the deadline, the URL checks and the Content-Length check; tests for a URL with user info, without a host, with http, and the stall test refuses at the deadline. The deadline is a clamped per-read timeout (no separate branch), the redundant password check is gone (a password always comes with a user), and the timed_out mutant is documented as equivalent (fread() returns false on a TLS read timeout). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Membership sync v2, reader side in pgacc: the member list comes as JSON from the membership system's internal
members.php(PPOE/admidio-addons#1). This replaces the old encryptedadm_names.phpfetch.getusers.phpfetchesmembers_urlwith PHP streams:verify_peer/verify_peer_nameon,cafile=members_cafile(the peer certificate), Bearer token, no redirects, 20 s timeout, HTTP 200 required. It usesfopen+stream_get_contents(4 MiB + 1)and refuses a body over 4 MiB or a read that timed out, the same shape asaccsync_fetchon the membership side.loint or null,paid0/1. A malformed or duplicated list is refused (fail closed, as before). The LO mapping is unchanged (44, unknown or null → 10).ppmembersstores theuuid.mb.phplinks Admidio profiles byuser_uuid(only a valid UUID goes into the link); the ledger (closed.php) and the voucher form (new.php) show the member id as plain text.sync-secrets.php:members_url,members_token,members_cafile. An unparsable or throwing file fails closed with "Mitgliederliste nicht konfiguriert!" (include in try/catch, only the exception class is logged) instead of a PHP fatal.sync-secrets.phpcomes from the inventory. One Ansibletemplatetask (templates/sync-secrets.php.j2, root:pgacc 0640,no_log) writes it on every run. There is nocreates:and no lineinfile. The template renders themembers_*keys whilepgacc_members_urlis set and thepayments_*keys (Sync v2: internal payment endpoint (provider side) #83) while the internal listener is on. The task and the template are identical in Sync v2: internal payment endpoint (provider side) #83, and so istests/runtime/test-sync-secrets.php. Variables:pgacc_members_url,pgacc_members_token(64 hex, asserted) andpgacc_members_cert, empty by default. The certificate now goes to/etc/pgacc/admidio-addons-tls.crt, following the/etc/<app>/<peer>-tls.crtconvention of PPOE/admidio-addons. The member-list asserts and certificate tasks are separate tasks, so the playbook merges with Sync v2: internal payment endpoint (provider side) #83 without conflicts.adm_names.phpfetch andmembership_decrypt().pgacc_timezone: Europe/Vienna. These shared sections are worded the same as in Sync v2: internal payment endpoint (provider side) #83.deploy.sh, template and test config merge cleanly.Follow-up after both #83 and #84 are merged: delete the helpers that are orphaned only then (
membership_cipher_params(), the membership stub helpers, the mcrypt vectors and their tests, the related receipt-crypto mutation targets,$datakeyin the reference runtime).rijndael256_*stays (receipt v1).Tests: new GetUsersTest cases (bad, wrong-name or untrusted certificate, 500/403/redirect, 19 malformed lists, UUID validation, link rendering). Red first in this round: a body of 4 MiB + 1 is refused while exactly 4 MiB is read; a stalled body (new stub mode
stall) is refused on timeout; an unparsable or throwingsync-secrets.phpfails closed.http-importchecks the links on all three pages. The PHP 5 reference was re-recorded in the first round (links, uuid in the SQL, stub path); no re-record was needed this round. Mutation on the new fetch/config lines: 5/5 killed, plus 12/12 on the earlier getusers changes. Astra review of this round: not run, codex usage limit until 05:37.🤖 Generated with Claude Code