Skip to content

edgraph: add AlterNoAuth for trusted in-process schema callers#9748

Open
matthewmcneely wants to merge 1 commit into
mainfrom
oss-alter-noauth
Open

edgraph: add AlterNoAuth for trusted in-process schema callers#9748
matthewmcneely wants to merge 1 commit into
mainfrom
oss-alter-noauth

Conversation

@matthewmcneely

Copy link
Copy Markdown
Contributor

What

Adds AlterNoAuthAlter without the admin-IP-whitelist and ACL authorization checks — mirroring the existing Query/QueryNoAuth pair, for trusted in-process callers.

  • validateAlterOperation gains an AuthMode: the structural checks (field set, health, mutations-allowed, reserved-namespace) always run; the IP-whitelist and ACL checks run only under NeedAuthorize.
  • Alter and AlterNoAuth share a private alter().
  • AlterNoAuth is restricted to schema operations — isDropOperation refuses every drop form — so bypassing auth can never be used to remove data. It must not be exposed to network clients.

Why

An in-process caller using context.Background() carries no gRPC peer, so x.HasWhitelistedIP fails with "unable to find source ip" on every config — not only under --security whitelist. QueryNoAuth already solves this for queries; AlterNoAuth is its schema-write counterpart.

Tests

edgraph/alter_noauth_test.go (white-box) exercises the validateAlterOperation auth gate — a background context is rejected under NeedAuthorize, accepted under NoAuthorize, and the structural/health checks still fire — plus AlterNoAuth's drop refusal. No cluster needed.

Alter routes every caller through validateAlterOperation, which calls
hasAdminAuth -> x.HasWhitelistedIP. That extracts the source IP from the
gRPC peer, so a caller running with a context.Background() (no peer) is
always rejected with "unable to find source ip" — regardless of the
--security whitelist setting.

Split Alter into Alter (NeedAuthorize) and AlterNoAuth (NoAuthorize) over
a shared alter(), mirroring Query/QueryNoAuth. validateAlterOperation now
takes an AuthMode: the structural checks always run, while the IP-whitelist
and ACL checks run only under NeedAuthorize.

AlterNoAuth is restricted to schema operations via isDropOperation — drop
requests are refused so bypassing auth can never remove data. It must not
be exposed to network clients.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matthewmcneely matthewmcneely requested a review from a team as a code owner June 17, 2026 18:53
@github-actions github-actions Bot added area/testing Testing related issues go Pull requests that update Go code labels Jun 17, 2026
@matthewmcneely matthewmcneely requested a review from mlwelles June 17, 2026 21:08
Comment thread edgraph/alter_noauth_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing Testing related issues go Pull requests that update Go code

Development

Successfully merging this pull request may close these issues.

2 participants