Strapi 4: How to override the "authenticate" method in strategies to implement custom JWT validation logic

System Information
  • Strapi Version: 4.6.1
  • Operating System: macOS 13.1
  • Database: MySQL 8
  • Node Version: 18.12.1
  • NPM Version: 8.19.2
  • Yarn Version: N/A

I have implemented a custom JWT by overriding the “callback” method in the file src/extensions/users-permissions/strapi-server.js

The JWT now does not contain just the id parameter, but also contains a few other parameters, which are needed for my application.

To validate all API calls, I need to override the authenticate method provided in this file

How do I override this method? I thought placing some code in src/extensions/users-permissions/strapi-server.js should work, but I am not able to make it work. Any suggestions on how to do this?

1 Like

Hi, did you manage to find solution for above?

you also need to copy the register.js file and update the authStrategy path and sanitizers inside this file and in the constant specPath point to content-api.yaml inside the node_module