PAT validation error is assigned in context.user
context.user is assigned an error response from Validate PAT lambda function if an invalid token is sent.
This is:
- Bug
Expected Behavior
You should see context.null === null
Actual Behavior
You get context.null === "{ errors: {...}, statusCode: 500, headers: {...} }"
Steps to Reproduce the Problem
Send an invalid AT and you should encounter this issue.
Possible Solution
Update authenticatePat plugin, and make sure that when you invoke the ValidatePAT Lambda function, the returned response is not an error but actually user data.
Currently the code at packages/api-security/src/plugins/authentication/authenticatePat.ts:20 simply assigns whatever the response is. Check for errors here.
Since I'm currently in the middle of refactoring the security and Headless CMS backend code, I'll take a look at this.
Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Slack Community or ping one of the reviewers. Thank you for your contributions!