Repository navigation
feat(geolocation): finalize signer geolocation backend with IP-based location - #8414
Conversation
|
Codecov Report❌ Patch coverage is
... and 224 files with indirect coverage changes 🚀 New features to boost your workflow:
|
31f7c03 to
fd0841f
Compare
fd0841f to
521efbf
Compare
YvesCesar
left a comment
There was a problem hiding this comment.
Many thanks for your contribution, @lfals :)
I added a few points for review.
A question:
About the 3rdparty submodule bump in this PR: it points to 2e04147, which is only reachable from the fork branch, right? LibreSign/3rdparty#101 was closed without being merged, so geoip2/geoip2 currently has no home in LibreSign/3rdparty. The commit itself is fine (the scoped package is there under composer/geoip2/geoip2/), it just needs to land on a LibreSign/3rdparty branch and the SHA retargeted before this can be merged.
|
@YvesCesar , 3rdparty submodule updated! |
|
@vitormattos behat failing again, now we have logs. I'll take a look, but feel free to do too |
|
Thanks, @lfals @vitormattos this PR looks good to me. |
c3266e2 to
0730106
Compare
0730106 to
3c22341
Compare
Pin the submodule to the local commit that ships the scoped MaxMind GeoIP2 reader for City database lookups. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Introduce GeoIP configuration, database validation, lookup/normalization services, and admin GET/POST /api/v1/admin/geoip for LibreSign#8086. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Rename the device policy/API fields, freeze write-once snapshots, nest device metadata under geolocation.device, and collect IP evidence before the sync/async signing split for LibreSign#8086. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Refresh OpenAPI specs and generated TypeScript types for the final signer geolocation and admin GeoIP APIs. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Rename device geolocation fields/policy keys and read nested geolocation.device so existing flows stay green ahead of LibreSign#8087. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Validate IP status and unavailable reason enums when exposing stored geolocation metadata through the file list API. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
REUSE requires LICENSES/Apache-2.0.txt for the MaxMind test database attribution used by the GeoIP lookup tests. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Envelope snapshots may only contain enable_observer_profile, so treat device geolocation as frozen only when its snapshot entry is present. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Expose geolocation.ip.sourceIp only to the signer themselves or the request owner, matching rejection metadata visibility rules. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Derive database readiness from the cached reader instead of calling getStatus() first, and drop the unused AddressNotFound helper. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Extract envelope/child snapshot lookup into one trait so device, IP, and rejection policies keep the same oldest-child rule. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
The geolocation freeze closure no longer reads the requester user. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Satisfy prefer-object-has-own eslint rule in IdentifySigner. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
findSnapshot is typed as array<string, mixed>, so returning it from getPolicyValue violated the declared policy shape. Route through the typed normalizer and mark trait implementations with Override. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
findSnapshot was array<string, mixed>, so getPolicyValue could not honestly return the policy shape. Move envelope/child lookup into FrozenFilePolicySnapshotResolver<T> and drop the trait abstracts that only passed under Override attributes. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Point the submodule at the merged LibreSign/3rdparty#101 tip so the geoip2 package is reachable from the official repo before merge. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
An envelope never carries the geolocation snapshots itself, they are frozen on its child files. sync() therefore resolved the current policy and wrote it on the envelope, and the snapshot resolver then preferred that value for every child, replacing the frozen one after a policy change. Skip sync on envelopes, like the rejection applier does. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
v15.0.0 to v15.0.3 stored the device geolocation policy as signer_geolocation, the signer requirement as geolocationRequirement and the collected payload flat under geolocation. Rename them in app config, user preferences, group permission sets, file policy snapshots and sign request metadata so upgraded instances keep enforcing the configured policy and in-flight requirements. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
MySQL JSON does not preserve object key order the same way as SQLite, so assertSame on nested policy_snapshot entries failed even when the rename itself succeeded. Sort keys recursively on both sides. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
After rebasing onto main, retarget the submodule to the current LibreSign/3rdparty tip already used on upstream main. Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
3c22341 to
b0062d4
Compare
Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
There was a problem hiding this comment.
Thanks, Luiz.
I reviewed the latest push. The migration now processes metadata in bounded batches, so the memory concern from the previous review is addressed. The current CI is also fully green, including the Playwright suite.
For the Playwright environment itself, we created separate follow-up work to align LibreSign with the current Nextcloud E2E/Playwright pattern and later consume the shared LibreCode workflow:
These are follow-up improvements to the test environment and are not blockers for this PR.
From my side, this is ready to approve.
Resolves: #8086
📝 Summary
Finalizes the signer geolocation backend for #8086:
signer_device_geolocationandsigner_ip_geolocationdeviceGeolocation*) and nested stored metadata undergeolocation.{device,ip}LibreSign/3rdparty(geoip2/geoip2)GET/POST/api/v1/admin/geoipIRequest::getRemoteAddress(), collected before the sync/async signing split; failures never block signingMinimal frontend renames keep existing device flows green. Full GeoIP / Policy Workbench / audit UI remains #8087.
🧪 How to test
.mmdbpath (e.g.tests/php/fixtures/geoip/GeoIP2-City-Test.mmdb).GET /ocs/v2.php/apps/libresign/api/v1/admin/geoipPOST /ocs/v2.php/apps/libresign/api/v1/admin/geoipwith{"path":"..."}Confirm status and that no signer data is returned.
signer_device_geolocation→requiredsigner_ip_geolocation→enabledpolicy_snapshot.deviceGeolocation→ 422.deviceGeolocation→ 200; metadata includesgeolocation.deviceandgeolocation.ip(at leaststatus+sourceIp).composer test:unit -- --filter GeoIpcomposer test:unit -- --filter SignerIpGeolocationtests/integration/features/sign/signer_geolocation.featuretests/integration/features/policies/signer_geolocation_policy.featureHow to see this running using GitHub Codespaces
1. Open the Codespace
Codebutton and select theCodespacestab.2. Wait for the environment to start
✍️ LibreSign is up!3. Access LibreSign in the browser
4. Login credentials
adminadmin🎨 UI / Front‑end changes
deviceGeolocation,deviceGeolocationRequired,deviceGeolocationRequirement)geolocation.devicein validation/sign helperssigner_device_geolocation(IP policy UI deferred to Finalize signer geolocation frontend with IP-based location #8087)🚧 Tasks
⚙️ API / Back‑end changes
geolocation.device/geolocation.ip; independent fromcollect_metadatageoip2/geoip2through scopedLibreSign/3rdpartyLICENSES/Apache-2.0.txtfor MaxMind test fixture attribution🚧 Tasks
feat/geoip2-dependency) and retarget the submodule if the merged SHA differs from2e04147✅ Checklist
🤖 AI (if applicable)