Skip to content
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

Clerk middleware for resolvers working #102

Closed
wants to merge 2 commits into from
Closed

Conversation

raheeqi
Copy link
Collaborator

@raheeqi raheeqi commented Sep 27, 2024

Goal: Improve security and get the graph ql resolvers working again

  • Global Clerk authentication middleware (clerkMiddleware()) for user verification via JWT, so no more manual auth middleware
  • Helper function getUserFromHeaders decodes the JWT from request headers to verify the user in each resolver, helps readability and decreases LOC
  • The userID from decoded JWT ensures that each request is tied to the authenticated user
  • Eliminates the need for manually parsing the JWT in each resolver
  • Using decodedToken.sub for filtering data specific to the authenticated user, rather than the old code using args.userID directly
  • verifying the JWT on every request
  • separating middleware and JWT verification logic from resolver logic

Copy link
Collaborator

@am5815 am5815 left a comment

Choose a reason for hiding this comment

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

looks good

@raheeqi raheeqi closed this Oct 2, 2024
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.

2 participants