Skip to content

Commit

Permalink
added message to catch machine token to user auth and added changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobevangelista committed Jan 14, 2025
1 parent 89949d4 commit ea44d14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/thin-stingrays-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/backend': minor
'@clerk/nextjs': minor
---

Added machine to machine auth
4 changes: 4 additions & 0 deletions packages/backend/src/tokens/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ ${error.getFullMessage()}`,

async function authenticateRequestWithTokenInHeader() {
const { sessionTokenInHeader } = authenticateContext;
const { data: decodeResult } = decodeJwt(sessionTokenInHeader!);
if (decodeResult?.payload.sub.startsWith('mch_')) {
return signedOut(authenticateContext, 'Machine tokens cannot be used to authenticate user requests');
}

try {
const { data, errors } = await verifyToken(sessionTokenInHeader!, authenticateContext);
Expand Down

0 comments on commit ea44d14

Please sign in to comment.