Repository navigation
Roles can limit the networks their members use the web UI and API from - #2109
Merged
Merged
Conversation
Issue #2107. A role gets an Allowed Networks list (addresses and CIDR ranges, IPv4 and IPv6). A user whose roles carry lists may sign in to the web UI and use the REST API only from an address in the union of those lists. A role with no list does not lift another role's limit. Empty everywhere means no restriction, which is every existing install. The iPXE menu login, the advanced menu, and FOS checkcredentials are not limited: they prove the credential through passwordValidate() / authenticate(), which carry no network check, so a technician can still start a task from the boot menu on any network. Gates: - establishSession(): a new sign-in, any provider. After the FOGUser rebind, so it tests the account the session is stamped with. - LoadGlobals: an existing session, on every request. Nothing downstream re-checked the account, so a session (or a replayed session cookie) kept working from anywhere. This also drops an existing session of an account marked API-only, which had the same gap. - _isLoggedIn() plus ProcessLogin: the remember-me replay. ProcessLogin now unbinds the cookie's account when isLoggedIn() refuses it; before, the pages rendered anyway, because they test only isValid(). - Route: token, Bearer and basic-auth API clients get 403. validatePw() now mints the remember-me cookie only after establishSession() accepts the sign-in, so a refused sign-in leaves no userAuths row behind. REMOTE_ADDR only, never X-Forwarded-For. Loopback gets no exception: a reverse proxy on the server would make every request loopback and the limit would silently pass everyone. Role::save() refuses an edit that would lock out the user making it. Schema 461 adds roles.rAllowedNetworks varchar(2048). OpenAPI: no hand edit. The new role field is in $databaseFields and the manifest, so _entitySchema() emits it. The new 403 on the token paths is covered by the generic '403' response every operation already documents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 18, 2026
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.
For #2107.
What changes
A role gets an Allowed Networks field: addresses and CIDR ranges, IPv4 or IPv6, separated by commas, spaces, or new lines. If any role a user holds has a list, that user can sign in to the web UI and use the REST API only from an address in the union of those lists. A role with no list does not lift another role's limit. If no role has a list, nothing changes. That is every existing install.
Not limited: the iPXE menu login, the advanced menu login, and FOS
checkcredentials.php. A technician can still start a task from the boot menu on any network, which is the point of the issue.Behavior to know about
REMOTE_ADDR).X-Forwarded-Foris never read, because the caller writes it. Behind a reverse proxy every request carries the proxy's address, so the feature cannot tell users apart there. The help text on the field says so.127.0.0.1.roles.rAllowedNetworksin the database. Adding yourself to a limited role from outside its networks is not guarded._isLoggedIn()refused it, but most callers ignore that return. This is the same gap the network check had, on the same call path.userAuthsrow behind.How
User::establishSession()FOGUserrebind, so it tests the account the session is stamped with.LoadGlobalsUser::_isLoggedIn()plusProcessLoginProcessLoginnow unbinds the cookie's account whenisLoggedIn()refuses it. Before, the page rendered anyway, because the pages test onlyisValid().RoutepasswordValidate()andauthenticate()deliberately carry no network check, because iPXE and FOS share them.Schema 461 adds
roles.rAllowedNetworks varchar(2048). OpenAPI needs no hand edit: the field is in$databaseFieldsand the manifest, and every operation already documents a generic 403.Tests
tests/role-allowed-networks.test.phphas 48 checks. The list parser, the matcher,networkAllows(), and the shared session testsessionPermittedHere()all run. The gate placements are checked against the source. I made the test fail on purpose by removing theLoadGlobalsgate, theProcessLoginunbind, and the network clause in turn, and each removal turned it red.tests/api-only-users.test.phpnow pins the API-only refusal through the shared session test.tests/fixtures/route-column-contract.txtgains the new role column.🤖 Generated with Claude Code