Skip to content

Accept Basic client auth, deliver sent Gmail, and support service accounts in the Google emulator - #406

Open
ctate wants to merge 5 commits into
mainfrom
ctate/accept-basic-client-ee90fa
Open

ctate wants to merge 5 commits into
mainfrom
ctate/accept-basic-client-ee90fa

Conversation

@ctate

@ctate ctate commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
emulate Ready Ready Preview, v0 Nov 15, 2026 6:04pm UTC

@Railly
Railly self-requested a review November 14, 2026 02:18

@Railly Railly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a few comments

Comment on lines +177 to +183
const accessToken = issueAccessToken(
store,
tokenMap,
user ?? { email: account.client_email, id: 0 },
scope,
revocationKey,
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with google.strict_scopes, tokens issued without sub get 401 on every api route instead of acting as the service account. let the user lookup in the auth middleware fall back to seeded service accounts, or say in the docs that strict mode needs sub.

repro: seed strict_scopes: true, POST /oauth2/token with a signed assertion without sub (scope drive) then GET /drive/v3/files with the token -> token is 200, the api call is 401 UNAUTHENTICATED (same token flow returns 200 without strict mode)

const user = gs.users.all().find((candidate) => candidate.email.toLowerCase() === address);
if (!user) continue;
if (address === sender) {
result = markMessageModified(gs, result, [...result.label_ids, "INBOX", "UNREAD"]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a message sent to yourself gets INBOX and UNREAD back even when your own filter removed them, unlike the recipient copies. skip the labels the sender's matching filters remove.

Comment on lines +10 to +14
const TOKEN_AUDIENCES = new Set([
"https://oauth2.googleapis.com/token",
"https://accounts.google.com/o/oauth2/token",
"https://www.googleapis.com/oauth2/v4/token",
]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the emulator's own token url is refused as aud, and go's x/oauth2 signs exactly that when token_uri points here. accept ${baseUrl}/oauth2/token as an audience too.

@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

The mailbox-list parser stopped an atom at every character that can end
one, but a closing parenthesis outside a comment or a quoted string had
no branch of its own. The atom branch then began and ended at the same
position, so the tokenizer added empty atoms and never advanced. A From
supplied to messages.send or drafts.send could therefore block the
event loop.

A closing parenthesis that is not part of a comment now makes the header
invalid, and the atom branch refuses an empty token, so every iteration
either moves forward or rejects the header. Delivery then replaces the
malformed From with the sender's default send-as address, as it does for
any From that is not one checked mailbox.

The test "rewrites a malformed From without stalling" covers structured,
raw MIME, and draft sends, checks the recipient's From field and raw
header, and bounds the elapsed time.

This branch was successfully deployed

1 active deployment
Preview — 73c8c1ce Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants