Repository navigation
fix(ess): check creator ACL before provisioning XID and default owner to creator - #1323
Merged
Merged
Conversation
… to creator CreateExperiment used to create the XID first and only then ask the XID service whether the creator had WRITER on it. When a create was denied, the XID entry it had just made was left behind as an orphan (#1309). A request with unset ACLs was also rejected outright, and one with empty ACLs failed later in the XID service. Changes: - CreateExperiment now checks that the creator has WRITER (OWNER also counts) on the requested ACLs before calling CreateXidEntry. The check uses the injected AuthorizerInterface (internal/auth IsUserAuthorized), so user, group, domain, service account and all_authenticated_users grants all work. A denied create returns PermissionDenied and makes no XID entry. - The post-create XidService.CheckUserAuthorization call is removed because it duplicates the new check. Experiment XIDs are root entries, the XID service stores root ACLs exactly as sent, and CheckUserAuthorization runs the same internal/auth logic on them. - New validator.FillExperimentDefaultACLs: when ACLs are unset or list no principals in any role, the creator becomes the only OWNER. ACLs that list any principal are left alone, so access is never widened. The nil ACL check in ValidateCreateExperimentRequest is removed because unset ACLs now get this default. - The experiment and work unit metadata validators were identical after that removal, so they now share validateMetadataLimits (needed to pass the dupl lint). Error messages are the same as before. - The ESS Cloud Identity client now sets WithQuotaProject, like the XID service does, so group grants resolve the same way in both places. - Documented the new create-time authorization and ACL default in experiment.proto, docs/flows/experiment_lifecycle.md and docs/architecture/overview.md. Behavior changes: - Unset or empty experiment.acls now succeeds with the creator as OWNER. Before, unset ACLs got InvalidArgument and empty ACLs failed in the XID service. - A denied create no longer allocates an XID entry. Testing: - Table-driven TestCreateExperiment_CreatorAuthorization covers owner, writer, domain, all-authenticated-users, group (through the fake authorizer), reader-only and absent creators, authorizer deny and error, defaulted ACLs, and XID create failure. Every denied case asserts zero CreateXidEntry calls. - TestCreateExperiment_DefaultACLs runs end to end against the Spanner emulator and the real XID server. - TestFillExperimentDefaultACLs is a validator unit test. - run_affected_tests.py and pre-commit: 89/89 pass. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Follow-up to the review of the CreateExperiment ACL pre-check.
- experiment.proto: acls is now field_behavior OPTIONAL, because unset
ACLs default to the creator. This is a non-breaking relaxation. No
generated artifacts are checked in, so nothing was regenerated.
- ValidateCreateExperimentRequest now rejects malformed ACLs with
InvalidArgument before any defaulting or authorization happens:
- a role without a principal (shared validateACLRoles, which
ValidateCreateXidRequest now also uses)
- writers or readers listed with no owners (the same rule the XID
service applies to root XIDs)
Unset or empty ACLs are still accepted and get the creator default.
- New xidProvisionError helper for CreateXidEntry failures. gRPC status
errors from the XID service keep their code (for example
InvalidArgument or Unavailable); any other error is wrapped as
ErrInternal. Before, every XID failure was wrapped with %v and reached
the client as Unknown.
- validateArtifactMetadata now uses validateMetadataLimits for tags and
notes, finishing the DRY merge. Error messages are unchanged.
- FillExperimentDefaultACLs now documents that it modifies exp in place,
the same as FillExperimentNullValues.
- Tests:
- Renamed the fake-authorizer group case to
group_writer_allowed_by_fake_authorizer.
- Added cases for invalid ACLs (zero CreateXid calls), Internal for
non-status XID errors, and preserved XID status codes, plus validator
cases for invalid ACLs.
- TestCreateExperiment_DependencyFailures now configures the gke
execution environment so its cases reach the XID and storage calls
instead of passing vacuously.
TAG=agy
CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
There was a problem hiding this comment.
Code Review
This pull request updates the experiment creation flow to authorize the creator against the requested ACLs locally before provisioning an XID, preventing orphaned XID entries on authorization failure. It also makes the acls field optional, defaulting to the creator as the sole owner if unset or empty. To support this, validation and default ACL filling logic are introduced, and documentation and tests are updated accordingly. Feedback on the changes points out that wrapping a gRPC status error with fmt.Errorf in xidProvisionError causes it to lose its gRPC status code and details, and suggests using status.FromProto to preserve the status code while prefixing the message.
oauth2.ParseSessionToken accepted any HMAC algorithm and never checked iss or aud. Google and OIDC ID tokens were accepted without regard to their email_verified claim. Session tokens: - ParseSessionToken(tok, key, audiences...) takes the audiences the caller serves. It pins HS256, requires iss=SessionIssuer, an exp and a non-future iat (30s leeway), and an aud that contains any of the given audiences. Called with no audience it rejects every token, because jwt.WithAudience would otherwise skip the check. SessionIssuer and FrontendAudience are exported, and the token generator uses them. - The HTTP middleware (cookie and bearer paths) and the gRPC internal/auth session path accept FrontendAudience. Verified emails on gRPC: - Google ID tokens from accounts.google.com must carry email_verified=true. Every in-repo producer includes it: generateIdToken with includeEmail, gcloud print-identity-token --include-email, and metadata-server tokens with format=full, which google.golang.org/api/idtoken and google-auth fetch_id_token request. IAP assertions never carry the claim, so they are rejected only when it is present and not true. - JWKS/OIDC tokens are rejected when email_verified is present and not true. jwks.Claims exposes the raw claim, because providers disagree on whether it is a boolean or a string. - Refactor AuthenticateUserFromContext into resolveIdentity and per-path helpers; rename the shadowing errors slice to failures. Tests assert gRPC status codes. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
HMAC verification accepts an empty key, so ParseSessionToken now fails closed when secretKey is empty instead of validating tokens signed with no secret. Comment link: #1311 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
gRPC callers were authenticated (XMC session token, JWKS/OIDC token or Google ID token with a matching audience) but never ran the deployment admission check the HTTP middleware runs. Any Google service account from any project could mint an ID token for our audience and call the ESS, XID, dashboard, health and CMS gRPC APIs, and de-authorized users kept gRPC access with their session tokens. - internal/auth: add AdmissionChecker and run it after identity resolution on every path. Not admitted returns PermissionDenied; checker errors return Internal. NewAuthorizer takes AuthorizerParams and requires Admission. AdmitAll, AdmitPrincipals and AnyOf compose checkers. DeploymentAdmission maps DISABLE_AUTHENTICATION to AdmitAll (dev only, mirroring cms.NewDisabledAuthorizer); otherwise it returns the binary's oauth2.Authenticator, so gRPC and HTTP admit the same principals. - When a domain allowlist is configured, JWKS tokens must assert email_verified=true (RequireVerifiedJWKSEmail), because admitting by domain is only sound for verified emails. - Composition roots: ESS, XID, dashboard and health build their gRPC authorizer from the same Authenticator they use for HTTP. XID now builds one, closes it via its cleanup stack, and backfills GCP_PROJECT_ID from its quota project. Dashboard fails fast instead of serving with a typed-nil authorizer. Dashboard and health close their Authenticator. - Mock auth: replace ESS's auth_dev.go/auth_prod.go with the build-tagged mock.ConfigureIfEnabled, called in all four roots. ESS behavior is unchanged; in binaries built without the mockauth tag it is a no-op. - CMS: a dedicated authorizer admits cfg.InvokerSA in addition to the deployment's principals. InvokerSA is ess_service_account = gcpServiceAccount = the ctk workload_service_account, which ctk binds to the xmc-bridge-sa KSA (xmc_wi_binding_xmc_bridge), so xmc-bridge keeps working without admitting that GSA anywhere else. The unused ProdServer.Authorizer accessor is removed. - Docs: deploy/helm/README.md "Deployment admission" (rod-data-provider gRPC is in-cluster only and unauthenticated) and corrected gRPC IAM and session claims in docs/design/gateway.md. Release note: human and service-account callers of the gRPC APIs must now be admitted like HTTP callers: through ALLOWED_EMAILS, ALLOWED_DOMAINS, or a direct AUTHORIZED_IAM_ROLE binding on the project. Owner, editor and group bindings do not count. CI service accounts may need an explicit binding or an allowlist entry. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
DeploymentAdmission returns nil for a nil authenticator. AnyOf now returns nil in that case so NewAuthorizer rejects it at startup, instead of panicking on the first request or silently narrowing admission. Comment link: #1312 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
initAuthorizer now returns the cloudidentity.NewService error instead of continuing with a nil service that would panic on group ACL checks, matching the experiment state server and XID service. Comment link: #1312 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
The OAuth callback admitted whatever email the identity provider returned. It never checked `email_verified` or Google's hosted domain (`hd`) claim and compared emails without normalizing them, so a consumer Google account registered with a corporate address was admitted through ALLOWED_DOMAINS as a member of that domain. - Extend GoogleUserInfo with `email_verified` and `hd` (both returned by Google's and Dex's userinfo endpoints). - Add admitLogin/verifyUserInfo (login_identity.go): the email must be verified; when Google is the identity provider and the email's domain is in ALLOWED_DOMAINS, `hd` must itself be an allowed domain (so alias and secondary domains of an allowlisted Workspace still pass, and accounts without `hd` do not). The check applies even if the address is also in ALLOWED_EMAILS. Non-Google OIDC providers (Dex, Okta, ...) never set `hd`; for them only `email_verified` is required. Google is detected as before via Config.IsNonProdAuth (AuthURL/issuer host accounts.google.com), wrapped as usesGoogleSignIn. - Emails are trimmed and lowercased before admission and before the Dashboard session token is minted. - Extract emailDomain/isAllowedDomain from IsUserAuthorized so admission and the `hd` check share one domain comparison. - Mock auth now reports a verified email so local logins keep working. Release note: Dashboard (and, with the CLI login that follows, CLI) session emails are now lowercased. Per-experiment ACL matching remains case-sensitive, so ACL entries with uppercase letters no longer match; normalizing ACL matching is a follow-up. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
verifyUserInfo now refuses a nil GoogleUserInfo as not admitted instead of dereferencing it. Comment link: #1313 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
First half of the server side of `xmc login` (#1309): the CLI opens the browser on /api/cli/login, the user signs in with the existing OAuth client, and the callback hands a one-time code to the CLI's 127.0.0.1 listener. The next change adds the endpoint that exchanges the code for a token. - GET /api/cli/login validates port (1024-65535), state (1-128 [A-Za-z0-9_-]), an S256 code_challenge (43 base64url) and an optional login_hint (bare email, forwarded to the IdP through new OAuthProvider.AuthCodeURL options); repeated parameters are rejected. Fetch metadata gates: Sec-Fetch-Site must be "none" (login CSRF: a page cannot start a CLI login in the user's browser and capture the code) and Sec-Fetch-Dest "document"; absent headers are allowed for old browsers (documented residual risk). It sets oauth_state and a host-only cli_login cookie (HttpOnly, Lax, Path=/api/callback, 5 min) holding {port, state, challenge, mode, H(oauth_state), exp}, MAC'd with an HKDF-SHA256 sub-key of the JWT secret (stdlib crypto/hkdf). - /api/callback takes the CLI branch only when that ticket is authentic, unexpired, in loopback mode and bound to this round trip's oauth_state; any cli_login cookie is deleted, and /api/login deletes it too, so a stale cookie cannot hijack a Dashboard login. The ticket is taken before the code/exchange checks, so every CLI outcome reaches the loopback listener: IdP error or cancel -> error=access_denied, exchange failure -> error=server_error, identity or admission rejection -> access_denied, admission/store failure -> server_error. Admitted users get 302 http://127.0.0.1:<port>/callback?code&state, built with net/url from the ticket only (never from request headers), with no-store and no-referrer. The email never goes in the URL. - One-time codes are 256-bit, stored only as SHA-256 with email, name, challenge and a 60 s expiry through oauth2.CLICodeStore. The Spanner implementation (internal/storage/spanner/clilogincode) and migration 016 create CliLoginCodes with a ROW DELETION POLICY; the PostgreSQL schema gets the same table for version parity (no store implementation; CLI login is wired only when a Spanner client exists). - ESS registers /api/cli/login only without MOCK_AUTH / DISABLE_AUTHENTICATION and with a Spanner client. Authenticator.EnableCLILogin is an init-only setter (refuses a second call) so pkg/auth/oauth2 builds no storage SDK. - Logs never include codes or verifiers, only the first 8 hex characters of the code hash. Size exception: this change is above the 400-line production threshold (about 870 lines by tools/analyze_diff_size.py) and is kept whole on purpose. It is the smallest reachable slice of the login flow: the ticket, the callback branch and the code store are only meaningful together, and splitting them would merge dead code or a callback that hands out codes no store keeps. The security controls (ticket MAC and oauth_state binding, fetch-metadata gates, loopback URL construction, strict parameter validation) belong in the same review as the flow they protect. Identity verification, the helm mock-auth guard and the token exchange are already split into their own changes. About 40% of the counted lines are license headers, doc comments, SQL DDL for two databases and BUILD files. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Add errExpiredCLILoginTicket, wrapping errInvalidCLILoginTicket, so the callback can tell an authentic but timed-out ticket (Info) from a forged or malformed one (Warn). Expired tickets are still rejected. Comment link: #1314 (comment) Comment link: #1314 (comment) Comment link: #1314 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Second half of the server side of `xmc login` (#1309): the CLI redeems the one-time code from the loopback callback, with its PKCE verifier, for an XMC session token scoped to the CLI. - POST /api/cli/token reads only the form body (never the query string, never cookies; 4 KiB cap, form content type required, repeated fields rejected). It checks grant_type=authorization_code and the format of code (43 base64url) and code_verifier (43-128 unreserved) before the store is touched, then consumes the code (Spanner read-write transaction: read by hash, delete) before checking expiry and the S256 verifier in constant time, so a wrong verifier burns the code. Every code or verifier problem returns 400 {"error":"invalid_grant"}; a user de-authorized since login gets 403 access_denied; malformed requests get invalid_request / unsupported_grant_type. Responses are always Cache-Control: no-store. - Flood protection: a process-wide token bucket (20 req/s, burst 40) spent only by well-formed requests, so malformed floods cannot lock out real logins (429 too_many_requests). Per-IP keying is not used: behind the load balancer all clients share proxy addresses. Residual: well-formed requests with random codes still reach Spanner, at most at that rate per replica. - The token is HS256 with the JWT secret, iss=SessionIssuer, aud=["xmanager-cloud-cli"] (oauth2.CLIAudience), sub/email = the normalized email, name, a random jti, and a lifetime from CLI_SESSION_TTL (helm auth.cliSessionTtl, default 12h, 1m-720h, validated in LoadConfig). The response is {access_token, token_type, expires_in, email}. Logs carry the jti, never the token. - The HTTP bearer path and gRPC parseCustomSessionToken accept FrontendAudience and CLIAudience; the session cookie still accepts FrontendAudience only. Every call re-runs deployment admission. - GET /api/cli/success is the static page the CLI redirects the browser to so the code leaves the address bar (no-store, no-referrer, nothing reflected, same fetch-metadata gate as the other browser endpoints). - ESS now also registers /api/cli/token and /api/cli/success. - Tests include a run through SecurityMiddlewares: the CLI's plain POST (no Origin, no fetch metadata) passes cross-origin protection and a cross-site browser POST is refused. - docs/design/gateway.md: the CLI token is listed among accepted bearer tokens. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Deployers can now list OAuth client IDs they own (for example their own Desktop OAuth client) whose Google ID tokens are accepted alongside the deployment's CLIENT_ID, instead of relying on the shared gcloud SDK audience (#1309). - oauth2.Config gains AdditionalAudiences, loaded from the comma/space separated ADDITIONAL_AUDIENCES env var. Entries are deduplicated in first-seen order. Startup fails if the list contains a shared public Google client (the gcloud SDK client 32555940559 or the gcloud ADC client 764086051850-...): any Google user can mint ID tokens for those, which would leave deployment admission as the only control. - Config.AcceptedAudiences(base...) is the single builder of the accepted audience list: base audiences, then ClientID, then AdditionalAudiences, in a deterministic order. base and ClientID pass through unchanged, so NewAuthorizer still fails fast at startup on an unset CLIENT_ID; additional audiences already present are skipped. The ESS, XID, dashboard and health gRPC authorizers and the ESS/XID JWKS validators now use it instead of hand-built slices. The health service keeps tolerating an unset CLIENT_ID by filtering it out. - The HTTP middleware's OIDC path accepts a token whose audience is any non-empty accepted audience (an empty audience would disable the aud check in idtoken.Validate). Admission (allowlists / IAM) is unchanged and still applies to every caller. - Helm: auth.additionalAudiences (default []) renders ADDITIONAL_AUDIENCES for every service using xmanager-cloud.oauthEnv. README documents the Desktop client setup, an InstalledAppFlow example, and why gcloud user tokens cannot be used. docs/design/gateway.md gains an "Accepted ID Token Audiences" section, linked from the CLI bearer-token list. Tests: table-driven tests for parsing, rejection, LoadConfig and AcceptedAudiences; NewAuthorizer still rejects an empty CLIENT_ID from AcceptedAudiences; middleware accept/reject/admission cases, including an empty CLIENT_ID never acting as a wildcard; a Helm render test across all six oauthEnv services. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Prepares the manual CLI login mode (#1309), which seals a second kind of value and renders more CLI pages. No behavior change. - sealSigned/openSigned/hmacSHA256 generalize the cli_login ticket MAC over any JSON value and key. - writeCLIResultPage/writeCLIPageHeaders factor out the no-store, no-referrer HTML page writing of /api/cli/success. - issueCLILoginCode takes the code TTL. TAG=agy
stillAdmitted re-runs deployment admission and logs a failure or denial, so the token endpoint and the manual login mode (#1309) report admission the same way. No behavior change. TAG=agy
`xmc login --no-browser` (#1309) cannot use a loopback listener over SSH or without a display. It sends `mode=manual` instead of `port`. - `/api/cli/login` requires exactly one of `port` and `mode=manual`; the ticket records the mode. - In manual mode the callback mints no code. After the identity checks and admission it shows an interstitial naming the account and warning the user to continue only if they ran `xmc login --no-browser` themselves. Its form carries a confirmation (email, name, challenge, nonce, 5m expiry) MAC'd with a new HKDF sub-key (`xmc-cli-manual-confirm-v1`). Failures render an error page. - `POST /api/cli/code` requires a same-origin top-level form post, verifies the confirmation, consumes its nonce record (domain-separated hash in CliLoginCodes, so it cannot be redeemed as a code), re-runs admission and shows a 120s code in the page body only. - Pages are no-store, no-referrer, script-free and html/template escaped. - Docs: helm README CLI login section and gateway.md headless flow, including the residual consent-phishing risk (gcloud parity). TAG=agy
Addresses the PR1b security review. - Cancel verifies the confirmation and uses up its nonce, like Continue, so a cancelled confirmation cannot be submitted later. - The form accepts only action=continue or action=cancel (else 400). - The manual mode re-checks admission through the shared stillAdmitted. - CLI login pages add `Content-Security-Policy: frame-ancestors 'none'; form-action 'self'`, enforced alongside the global policy. - Docs: the confirmation is a 5-minute bearer value not bound to the browser, a residual risk next to consent phishing. TAG=agy
Comment link: #1314 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…uthenticator Move MockOAuthProvider and ConfigureMockAuth from pkg/auth/oauth2/mock into pkg/auth/oauth2/mockauth_dev.go (//go:build mockauth) with a no-op configureMockIfEnabled in mockauth_prod.go (//go:build !mockauth), and invoke configureMockIfEnabled inside NewAuthenticator so production service binaries do not import a mock package or call a separate hook. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…n-authorize TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…ity-verification TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Replace the custom base64url(JSON).base64url(HMAC-SHA256) envelope and manual unix expiry comparison in cli_login_ticket.go with sealSigned and openSigned backed by github.com/golang-jwt/jwt/v5 (HS256, WithValidMethods, WithExpirationRequired) using the HKDF-derived cli_login key. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…ation Replace the manual SHA-256 + base64.RawURLEncoding computation in verifyPKCES256 with oauth2.S256ChallengeFromVerifier from golang.org/x/oauth2. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…iences TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…ogin-headless-helpers TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…login-headless TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
oauth2.ParseSessionToken accepted any HMAC algorithm and never checked iss or aud. Google and OIDC ID tokens were accepted without regard to their email_verified claim. Session tokens: - ParseSessionToken(tok, key, audiences...) takes the audiences the caller serves. It pins HS256, requires iss=SessionIssuer, an exp and a non-future iat (30s leeway), and an aud that contains any of the given audiences. Called with no audience it rejects every token, because jwt.WithAudience would otherwise skip the check. SessionIssuer and FrontendAudience are exported, and the token generator uses them. - The HTTP middleware (cookie and bearer paths) and the gRPC internal/auth session path accept FrontendAudience. Verified emails on gRPC: - Google ID tokens from accounts.google.com must carry email_verified=true. Every in-repo producer includes it: generateIdToken with includeEmail, gcloud print-identity-token --include-email, and metadata-server tokens with format=full, which google.golang.org/api/idtoken and google-auth fetch_id_token request. IAP assertions never carry the claim, so they are rejected only when it is present and not true. - JWKS/OIDC tokens are rejected when email_verified is present and not true. jwks.Claims exposes the raw claim, because providers disagree on whether it is a boolean or a string. - Refactor AuthenticateUserFromContext into resolveIdentity and per-path helpers; rename the shadowing errors slice to failures. Tests assert gRPC status codes. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
…rCLILogin - Expose `CLILoginCodes() CLILoginCodeRepository` on `storage.Storage`, `internal/storage/spanner.Storage`, `internal/storage/postgres.Storage`, and `storage.MockStorage`. - Add PostgreSQL `clilogincode.Repository` returning `codes.Unimplemented`. - Update `cmd/experiment_state_server` (`registerCLILogin`) to accept `prodServer.Storage()` instead of importing `internal/storage/spanner/clilogincode` or `*spanner.Client`. - Update `internal/storage/AGENTS.md` (§3) to instruct callers in `cmd/` and `internal/` to depend on `internal/storage` rather than importing engine-specific subpackages directly. Comment link: #1314 (comment) Comment link: #1314 (comment) TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
Implement `Consume` returning `codes.Unimplemented` on PostgreSQL `clilogincode.Repository` after merging `feat/cli-login-authorize`. TAG=agy CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c
VLukiantsev
force-pushed
the
fix/create-experiment-acl-check
branch
from
October 21, 2026 15:42
8d6b998 to
1b5cc91
Compare
VLukiantsev
marked this pull request as ready for review
October 21, 2026 15:42
VLukiantsev
force-pushed
the
fix/create-experiment-acl-check
branch
from
October 21, 2026 15:53
1b5cc91 to
9767032
Compare
janzak-dev
approved these changes
Oct 22, 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.
Summary
CreateExperimentnow checks that the creator has write access to the requested ACLs before it creates the XID entry, so a denied create no longer leaves an orphaned XID. Experiment ACLs become optional: when they're unset or empty, the creator becomes the only owner. Malformed ACLs are rejected up front, and XID error codes now reach the client unchanged.Stack position: standalone, based on
main. It doesn't depend on the CLI login stack, but it makes per-user CLI identities (#1309) usable: users can create experiments without writing their own ACL.Motivation & Context
CreateExperimentcreated the XID first and only then asked the XID service whether the creator hadWRITERon it. A denied create therefore left an orphaned XID entry behind.Unknown.Key Changes
CreateXidEntry: the creator must haveWRITERorOWNERon the requested ACLs. The check uses the injectedAuthorizerInterface, so user, group, domain, service-account andall_authenticated_usersgrants all work. A denied create returnsPermissionDeniedand makes no XID entry. The redundant post-createCheckUserAuthorizationcall is removed.validator.FillExperimentDefaultACLs: when ACLs are unset or list no principals, the creator becomes the onlyOWNER. ACLs that list any principal are left alone, so access is never widened.ValidateCreateExperimentRequestrejects malformed ACLs withInvalidArgument: a role without a principal, or writers/readers listed without owners. This is the same rule the XID service applies to root XIDs.xidProvisionErrorkeeps gRPC status codes from the XID service. Other errors becomeInternal.experiment.proto:aclsis nowOPTIONAL, a non-breaking relaxation.WithQuotaProject, like XID, so group grants resolve the same way in both services.validateMetadataLimits. Error messages are unchanged.experiment_lifecycle.mdandoverview.mddescribe the create-time authorization and the ACL default.Behavior change / release note
experiment.aclsnow succeeds, with the creator asOWNER. Before, unset ACLs gotInvalidArgument, and empty ACLs failed in the XID service.InvalidArgumentbefore any side effect.InvalidArgumentorUnavailable) are now preserved instead of surfacing asUnknown.Assumptions
OWNERis the right behavior for empty ACLs. Why: it's the least-privilege default and matches the design decision for Authenticating local Python clients as individual users #1309. If wrong: teams that expected empty ACLs to fail must now validate this on the client.Verification & Testing
Commands Executed:
bazel build //api/protos/experiment:all //cmd/experiment_state_server/server:all //internal/validator:all,./tools/run_affected_tests.py --base-ref origin/main(Spanner emulator),./.githooks/pre-commit,./tools/analyze_diff_size.py --base-ref origin/main.Coverage & Test Status: the build succeeds. All 89 affected Bazel test targets pass, and
./.githooks/pre-commitpasses. Bazel line coverage of the lines this PR changes is 63/66 (95%):createexperiment.goandinternal/validator/requests.goare at 100%;WithQuotaProjectwiring inserver/prod.go.New tests:
TestCreateExperiment_CreatorAuthorization, a table test in which every denied case asserts zeroCreateXidEntrycalls;TestCreateExperiment_DefaultACLs, end to end against the Spanner emulator and a real XID server;Diff size: prod 110 / test 226 / docs 19 lines, below the split thresholds.
Live evidence: a GKE development deployment ran an integration build of the full stack.
CreateExperimentwith ACL owners=[creator]creator=<maintainer>CreateExperimentwithout ACL)PermissionDenied: creator … did not give themselves write permissionsXidsrow count 73 before, 73 afterRelated Issues / Bugs
Part of #1309.
TAG=agy
CONV=6dd806a4-f14e-436b-bef8-6b53e044b43c