Skip to content

Commit 1129f78

Browse files
docs(architecture): document the local session geo lookup subsystem
Sync the architecture reference with the new opt-in, local-only session geo lookup, in both the Markdown source and the rendered HTML: - Authentication & Authorization: new entry describing GeoLocator, the Auth.geoLookupEnabled gate (default off), null-safe failure behavior, the ci4ms:geoip-update command, and DB-IP CC BY 4.0 attribution. - CLI & Automation: new ci4ms:geoip-update table row.
1 parent b053860 commit 1129f78

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

docs/architecture.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,21 @@ <h2>Authentication &amp; Authorization</h2>
402402
<code>Modules\Backend\Filters\BackendLogFilter</code> (IP, user
403403
agent, action, module).
404404
</li>
405+
<li>
406+
<strong>Session geo lookup (local, opt-in):</strong>
407+
<code>Modules\Auth\Models\UserSessionModel::recordLogin()</code>
408+
can enrich a session with approximate city/region/country, resolved
409+
entirely against a <strong>local</strong> DB-IP City Lite database
410+
(MMDB) via <code>Modules\Auth\Libraries\GeoLocator</code>
411+
(<code>maxmind-db/reader</code>) — the IP address never leaves the
412+
server. Gated by the <code>Auth.geoLookupEnabled</code> setting
413+
(default <code>false</code>) and returns <code>null</code> on any
414+
failure, so it never breaks login. The database is
415+
downloaded/refreshed with <code>php spark ci4ms:geoip-update</code>
416+
(atomic swap, <code>flock</code>-guarded, monthly cron) and lives
417+
outside the web root under <code>writable/geoip/</code>. DB-IP data
418+
is CC BY 4.0 and requires attribution.
419+
</li>
405420
</ul>
406421
</section>
407422

@@ -671,6 +686,13 @@ <h2>CLI &amp; Automation</h2>
671686
<td><code>php spark cache:clear</code></td>
672687
<td>Clear all application caches</td>
673688
</tr>
689+
<tr>
690+
<td><code>php spark ci4ms:geoip-update</code></td>
691+
<td>
692+
Download/refresh the local DB-IP City Lite database for session
693+
geo lookup (monthly cron)
694+
</td>
695+
</tr>
674696
</tbody>
675697
</table>
676698
<p>

docs/architecture.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Authentication is powered by **CodeIgniter Shield** (`codeigniter4/shield`):
4040
- `Modules\Methods` manages these tables and can auto-scan routes to populate permissions.
4141
- Backend activity is logged via `Modules\Backend\Filters\BackendLogFilter` (IP, user agent, action, module) for audit trail purposes.
4242
- Inactive administrative sessions are secured via `Modules\Auth\Controllers\LockController` which locks the session and sets a `locked_at` timestamp.
43+
- **Session geo lookup (local, opt-in):** `Modules\Auth\Models\UserSessionModel::recordLogin()` can enrich a session with approximate city/region/country. Lookups run entirely against a **local** DB-IP City Lite database (MMDB) via `Modules\Auth\Libraries\GeoLocator` (`maxmind-db/reader`) — the IP address never leaves the server. The feature is gated by the `Auth.geoLookupEnabled` setting (default `false`) and returns `null` on any failure, so it never breaks login. The database is downloaded/refreshed with `php spark ci4ms:geoip-update` (atomic swap, `flock`-guarded, monthly cron); the file lives outside the web root under `writable/geoip/`. DB-IP data is CC BY 4.0 and requires attribution.
4344
- Application-wide rate limiting is enforced via `ThrottleFilter` and `Modules\Backend\Filters\BackendThrottleFilter` (HTTP 429).
4445
- Maintenance mode is gracefully handled by `Modules\Backend\Filters\BackendMaintenanceFilter` and the `BackendMaintenance` library (HTTP 503).
4546

@@ -135,6 +136,7 @@ Blog and Pages modules store SEO data as JSON (`coverImage`, `description`, `key
135136
| `php spark create:route` | Rebuild `app/Config/Routes.php` from the template |
136137
| `php spark migrate --all` | Run all pending migrations |
137138
| `php spark cache:clear` | Clear all application caches |
139+
| `php spark ci4ms:geoip-update` | Download/refresh the local DB-IP City Lite database for session geo lookup (monthly cron) |
138140

139141
`Modules\Methods::moduleScan()` inspects the router to align routes with permission records.
140142

0 commit comments

Comments
 (0)