-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(clerk): Remove privateMetadata property from getCurrentUser #7668
fix(clerk): Remove privateMetadata property from getCurrentUser #7668
Conversation
The privateMetadata property should not be accessible on the client side. This commit removes this property from the getCurrentUser function returned user object.
16 replays were recorded for d18ab63.
|
This won't fix the actual problem. Just stop the API using PrivateMetadata. I propose overwriting the default redwood currentUser with the ability to remove parts that you may want to be available in the backend context but not pass back to the front end, such as privateMetadata
|
Clerk need to override the default Example on how to remove privateMetadata being sent to the frontend useAuth Hooks export const resolvers: Resolvers = {
BigInt: BigIntResolver,
Date: DateResolver,
Time: TimeResolver,
DateTime: DateTimeResolver,
JSON: JSONResolver,
JSONObject: JSONObjectResolver,
Query: {
redwood: () => ({
version: redwoodVersion,
prismaVersion: prismaVersion,
currentUser: (_args: any, context: GlobalContext) => {
const { ...userWithoutPrivateMetadata, privateMetadata } = context?.currentUser
return userWithoutPrivateMetadata
},
}),
},
} |
It seems to be that the currentUser in global context — and the same info passed back to client — should be “safe” data to share. If private data is needed elsewhere in the api side (or web side) then I’d argue that should be an explicit request to ensure that it’s ok to show this info for the given user. I could see this being done: a) via a Clerk backed api call |
Another approach would be to do the “sanitizing” at the decoder level here:
if there is a Clerk api method that gets only a subset of “safe” user attributes and use that … or deconstruct there instead of in the getCurrentUser |
After discussing this in the team we decided that this is the quickest solution that's the best option for most people. |
The privateMetadata property should not be accessible on the client side. This commit removes this property from the getCurrentUser function returned user object. Co-authored-by: Stefanos Anagnostou <stefanos@clerk.dev>
* 'main' of github.com:redwoodjs/redwood: (21 commits) chore(deps): update dependency @types/uuid to v9.0.1 (redwoodjs#7680) chore(deps): update dependency @replayio/playwright to v0.3.23 (redwoodjs#7677) chore(deps): update dependency @npmcli/arborist to v6.2.3 (redwoodjs#7675) chore(deps): update dependency @envelop/types to v3.0.2 (redwoodjs#7674) chore: add codemod for clerk fix in v4.2.0 (redwoodjs#7676) chore(deps): update dependency @clerk/types to v3.28.1 (redwoodjs#7652) chore(deps): update dependency @envelop/testing to v5.0.6 (redwoodjs#7673) Update directives.md (redwoodjs#7670) fix(deps): update dependency vscode-languageserver-types to v3.17.3 (redwoodjs#7636) Fix `yarn rw exec` to set nonzero exit code on error (redwoodjs#7660) fix(deps): update dependency core-js to v3.28.0 (redwoodjs#7666) fix(deps): update dependency @clerk/clerk-sdk-node to v4.7.4 (redwoodjs#7663) fix(deps): update dependency vite to v4.1.3 (redwoodjs#7664) fix(deps): update dependency @fastify/url-data to v5.3.1 (redwoodjs#7665) fix(deps): update dependency yargs to v17.7.1 (redwoodjs#7667) fix(clerk): Remove privateMetadata property from getCurrentUser (redwoodjs#7668) chore(deps): update dependency esbuild to v0.17.10 (redwoodjs#7662) chore(deps): bump setup of Chakra UI to V2 (redwoodjs#7649) Forms: Export EmptyAsValue (redwoodjs#7656) Update useRequireAuth docs to v4 auth (redwoodjs#7646) ...
The privateMetadata property should not be accessible on the client side. This commit removes this property from the getCurrentUser function returned user object.