Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
enhancementNew feature or request
Milestone
Description
Let a request authenticate by where it comes from instead of by a credential. This is a kind of anonymous access where the client IP is the thing that gets validated. Different repositories can then accept different networks or single IPs. The typical cases:
- build agents on
10.20.0.0/16restore fromnuget-groupwithout a token; - one deployment host
192.0.2.15may pull fromdocker-releasesand nothing else; - the office network gets read access to the internal npm group.
Where things stand
auth.anonymous_mode = "allowlist"withauth.anonymous_ip_allowlist(CIDRs, or theloopback/private/localtokens) decides whether an unauthenticated request may become the anonymous principal (AnonPolicy,crates/core/src/auth/client_ip.rs).- What the anonymous principal may then do comes from the per-repository
anonymous_readflag and the built-inanonymousrole's grants. - The client IP comes from
resolve_client_ip, honouringauth.trusted_proxy_cidrs.server.allowed_hostsguards against DNS rebinding for the allowlist mode.
What's missing:
- There is one global list. "Network A may read repo X, network B may read repo Y" can't be expressed. Every allowlisted IP gets exactly what anonymous gets everywhere.
- The list lives in the config file only, so changing it needs a restart and isn't visible or auditable in the UI.
- There is no single-IP or IPv6 convenience, and no name or description per network.
Proposal
Network principals (or an "IP" auth realm), managed in the admin UI and API:
- A network rule has a name, a description, and one or more entries.
- Entries: single IPs (
192.0.2.15,2001:db8::5), CIDRs (10.20.0.0/16), and the existingloopback/private/localtokens. - Each rule can be enabled or disabled.
- Entries: single IPs (
- A rule is a principal. It is granted roles per repository through the existing RBAC (repository grants, content selectors), exactly like a user or group. Read is the normal case.
- Write (e.g. pushes from a CI subnet) must be possible but opt-in, with a warning in the UI.
- Admin is never grantable.
- Optional per-repository use. A repository grants a network rule like any other principal, and a rule granted on no repository does nothing.
- Evaluation
- Credentials, when sent, always win: a request with a token or session is that principal, never the network one. Whether a failed credential falls back to the network principal or is refused needs a decision; refusing is the safer default.
- Without credentials, every enabled rule containing the client IP applies, with the union of their grants. A request that matches no rule is anonymous, as today.
- The existing global
anonymous_mode/anonymous_ip_allowlistkeep working. They could be migrated into a built-in rule later.
- Safety
- Client-IP resolution is the existing XFF walk, with
trusted_proxy_cidrs. - The
allowed_hosts/public_base_urlhost check applies to network principals as it does to the allowlist mode. - A rule containing
0.0.0.0/0or::/0needs explicit confirmation. - The audit log records the rule name and the client IP for every write made through a network principal.
- Client-IP resolution is the existing XFF walk, with
- Caching: rules are cached per instance and invalidated across instances through the cache backplane on change, like other authz data.
Open questions
- Should a repository also be able to restrict access to networks for authenticated callers, i.e. a token works only from those IPs? This is related but a different feature: an extra condition, not a principal.
- Are per-token IP restrictions wanted as well?
Acceptance criteria
- Admin API + UI to create, edit, disable and delete network rules, and to grant them on repositories.
- Unit tests for matching: IPv4, IPv6, IPv4-mapped IPv6, single IP vs CIDR, tokens.
- Integration tests:
- repo A readable from net 1 only, repo B from a single IP only;
- a credentialed request is never downgraded;
- spoofed
X-Forwarded-Forfrom an untrusted peer is ignored.
- Works for every format's feed (NuGet now; the formats from Multi-format registry: Docker, npm, raw files, Helm, apt and Maven next to NuGet #37 as they land).
- Docs:
docs/deployment.mdexplains client-IP preservation behind a load balancer (trusted_proxy_cidrs; on KubernetesexternalTrafficPolicy: Localor the PROXY protocol at the ingress), since rules are only as good as the IP Forge sees.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity