fix(google): enforce OAuth authority in strict mode - #217
Open
ikatkov wants to merge 1 commit into
Open
Conversation
Contributor
|
@ikatkov is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Aug 28, 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
Fixes #218.
The Google emulator currently treats any nonempty bearer credential as authenticated through the core fallback user. That makes an unknown token, a revoked access token, and a refresh token presented as an access token indistinguishable from a valid credential. Google resource routes also ignore the scopes granted during OAuth.
This adds an opt-in
google.strict_scopesmode, following the compatibility pattern already used by the Linear and Slack emulators. When enabled, Google now:/oauth2/revoke401UNAUTHENTICATEDfor invalid credentials and403insufficientPermissionsfor scope missesStrict mode defaults to
false. Existing users can continue using arbitrary local bearer tokens without completing OAuth, with unchanged response statuses and bodies.Reproduction
Use a Google seed with an OAuth client, a user, and at least one Drive item:
Start v0.10.0 with
npx emulate@0.10.0 start --service google --port 4700 --seed emulate.config.yaml, then compare these requests:/drive/v3/fileswithBearer totally-bogus-token./oauth2/revoke, then call Drive with it again.openid, then call Drive, Gmail, and Calendar data routes.On v0.10.0, all five resource credential variants return
200and expose seeded data. With this change andgoogle.strict_scopes: true, the results are:200401 UNAUTHENTICATED200200200401 UNAUTHENTICATEDopenid-only token on Drive, Gmail, or Calendar200403 insufficientPermissions200401 UNAUTHENTICATEDCompatibility
strict_scopesis absent orfalseby default. Tests compare response bodies as well as status codes for unknown, revoked, underscoped, and refresh credentials to guard the existing permissive workflow.The starter config, package README, root README, docs site, Google skill, and CLI help now document the option.
Tests
pnpm testpnpm type-checkpnpm lintpnpm buildFollow-ups
The Microsoft and GitHub emulators have the same adjacent unknown-bearer fallback gap. They are intentionally out of scope here and can use the same opt-in pattern in separate changes. Consent denial and fault injection are also outside this PR.