Skip to content

fix(auth): quote the member key in the group-membership CEL query - #17

Open
Xyloslabs wants to merge 2 commits into
google-labs-code:mainfrom
Xylos-Labs:fix/group-allowlist-cel-query
Open

Xyloslabs wants to merge 2 commits into
google-labs-code:mainfrom
Xylos-Labs:fix/group-allowlist-cel-query

Conversation

@Xyloslabs

Copy link
Copy Markdown

The group-allowlist login path could never succeed: checkGroupMembership sends the member key to the Cloud Identity checkTransitiveMembership endpoint as an unquoted CEL expression (member_key_id == user@example.com). The API expects a quoted string literal (member_key_id == 'user@example.com'), rejects the unquoted form with a 400, and the error is swallowed, so the check always returns false. The domain allowlist and the * wildcard still work, so this only breaks group-based allowlisting.

This change adds a toCelStringLiteral helper that quotes the value, escaping backslashes and single quotes, and uses it when building the query. Two tests capture the URL sent to RestTemplate and assert the quoted expression, including a single-quote escaping case.

How it was checked: MembershipServiceImplTest run locally, 10/10 pass with the fix; the two new tests fail without it (8 pass / 2 fail). Note the repo has no Java CI workflow, so these were run locally: the test classpath was assembled from Maven Central with curl and run with the JUnit platform console, because mvn test cannot reach the network from this machine. Formatting was checked against google-java-format 1.22.0 (the repo's fmt-maven-plugin version).

Google CLA: signed.

The checkTransitiveMembership query is a CEL expression, so the member key must be a quoted string literal: member_key_id == 'member_key_id_value'. The unquoted email was rejected by the API (400), the error was swallowed, and the group-allowlist login path could never succeed. Quote the value, escaping backslashes and single quotes.
Capture the URL sent to RestTemplate and assert it contains member_key_id == 'user@example.com', plus a case with a single quote in the email asserting the escaping. Both fail without the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant