-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DB Auth] Generated auth handlers do not handle base64 encoded requests #3270
Labels
Comments
Here's an example of one of my handlers where I was handling a base64 encoded event. try {
if (event.isBase64Encoded) {
const stringBody = Buffer.from(body as string, 'base64').toString('ascii')
parsedBody = querystring.parse(
stringBody
) as unknown as PaddleSubscriptionHook
} else {
parsedBody = querystring.parse(
body as string
) as unknown as PaddleSubscriptionHook
} Types included for reference ;) - but we may not need to use the querystring library |
This is an example used in graphql.ts: /**
* Extracts and parses body payload from event with base64 encoding check
*
*/
const parseEventBody = (event: APIGatewayProxyEvent) => {
if (event.isBase64Encoded) {
return JSON.parse(Buffer.from(event.body || '', 'base64').toString('utf-8'))
} else {
return event.body && JSON.parse(event.body)
}
} |
cannikin
added a commit
that referenced
this issue
Aug 23, 2021
cannikin
added a commit
that referenced
this issue
Aug 25, 2021
* Handle base64 encoded event boy Closes #3270 * Update types for username and password * Fix all the squiggles with `value is string` Co-authored-by: Rob Cameron <rob.cameron@fastmail.com>
thedavidprice
pushed a commit
that referenced
this issue
Aug 27, 2021
* Handle base64 encoded event boy Closes #3270 * Update types for username and password * Fix all the squiggles with `value is string` Co-authored-by: Rob Cameron <rob.cameron@fastmail.com>
dthyresson
added a commit
that referenced
this issue
Aug 30, 2021
…ql handler (#3286) * Rework api and graphql-server, tests + e2e pass * Remove useEnvelop experimental flag * Rework errors * Rework api imports in graphql-server * Remove ApolloServer references * Update service generator for beforeResolver move * Remove webhooks, logger from graphql-server * Remove unused packages * Move Global Context into graphql-server * Update auto imports * Updates type generation * Removes corejs * Changes context import in rootSchema * Removes GlobalContext where not needed * resolve rhf explicitly (#3291) * Export redwood and prisma versions from api * add RedwoodProvider to mockProviders for unit testing (#3269) * dbAuth: Handle base64 encoded event body (#3275) * Handle base64 encoded event boy Closes #3270 * Update types for username and password * Fix all the squiggles with `value is string` Co-authored-by: Rob Cameron <rob.cameron@fastmail.com> * resolve rhf explicitly (#3291) * upgrade prisma v2.30.0 (#3290) Co-authored-by: Vincent Choy <vchoy@ccrhub.com> Co-authored-by: David Price <thedavid@thedavidprice.com> * update yarn.lock * v0.36.2 * update yarn.lock * Try reconfiguring ts | Add reference to api from gql-server Co-authored-by: Dominic Saadi <32992335+jtoar@users.noreply.github.com> Co-authored-by: Simon Gagnon <simon@mu2.ca> Co-authored-by: Rob Cameron <cannikin@fastmail.com> Co-authored-by: Rob Cameron <rob.cameron@fastmail.com> Co-authored-by: vchoy <vinchoy@gmail.com> Co-authored-by: Vincent Choy <vchoy@ccrhub.com> Co-authored-by: David Price <thedavid@thedavidprice.com> Co-authored-by: Daniel Choudhury <dannychoudhury@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's the issue?
Originally reported by Jace on Discord. When the /login and /signup function handlers are deployed on vercel, it errors out with:
Analysis
It seems this is because vercel base64 encodes incoming requests
Expected behaviour
The handlers should check if the event is base64 encoded, and decode it before continuing. (See example in comments)
The text was updated successfully, but these errors were encountered: