blob: bd13cadfc684666263b7d381b72028d8e094d8cd [file] [view] [edit]
The @PLUGIN@ module applies IP/CIDR restrictions to Gerrit project
permission checks. Passing IP policy does not bypass Gerrit's normal
permissions.
Architecture
------------
The module wraps `PermissionBackend` without Gerrit core changes. When a
checked user has a resolvable IP, it evaluates administrator-managed global
policy and then inherited project policy. Allowed checks delegate to
`DefaultPermissionBackend`; denied checks receive a denied project view,
behaving like a hidden project.
Global policy is controlled by server administrators, not project owners.
Its CIDR lists are always enforced, even when project policy uses
`LOG_ONLY`. See [configuration](config.md) for policy settings and
[metrics](metrics.md) for decision observability.
Project policy is read through `PluginConfigFactory` with inheritance and
uses Gerrit's project cache lifecycle for updates. Global policy is loaded
at startup and refreshed when an administrator runs `gerrit reload-config`.
Permission checks use the in-memory snapshot without checking the filesystem.
Failed reloads retain the current policy and log an error.
CIDR matching supports IPv4 and IPv6; prefixes from one address family do
not match addresses from the other.
Client address and proxies
--------------------------
Authenticated HTTP and SSH checks use `IdentifiedUser.getRemotePeer()`.
Anonymous HTTP checks use Gerrit's transport peer through the configured
`IpSubnetHttpFilter`, including change-search visibility checks. For checks
without a peer, see `failClosedOnMissingRemotePeer` in the
[configuration reference](config.md).
For deployments behind a proxy or load balancer, see Gerrit's
[`httpd.enableProxyProtocol`](../../../Documentation/config-gerrit.html#httpd.enableProxyProtocol)
and
[`sshd.enableProxyProtocol`](../../../Documentation/config-gerrit.html#sshd.enableProxyProtocol)
settings for preserving the original client address. For HTTP header-based
forwarding, see
[`httpd.listenUrl`](../../../Documentation/config-gerrit.html#httpd.listenUrl).
Follow the linked trusted-proxy security requirements to prevent source
address spoofing, and check that your Gerrit version supports these settings.
Enforcement scope
-----------------
The module protects operations that check project permissions, including
project visibility, Git fetch/push over HTTP and SSH, and project-scoped
REST/UI operations. It is not a transport-layer firewall: connection setup
and authentication may happen before access is denied. Non-project endpoints
and operations that do not consult project permissions are outside its scope.
Use firewall, proxy, or other endpoint controls where broader filtering is
required.
For a staged rollout, use `LOG_ONLY` on pilot projects before switching to
`ENFORCE`. Global CIDR lists remain enforced in either mode. Enable
`logDecisions` during validation; [metrics](metrics.md) are recorded
regardless of that setting.