Overriding API Admin Authentication in V2 #8682
Replies: 3 comments 3 replies
-
Signed up for updates on this topic. I find Medusa v2's built-in authentication to be just awful and very non-functional + completely non-flexible. I've been trying to do something similar and implement my own way of authenticating both administrative routes and client routes using next-auth. After studying a bit the authentication module of Medusa v2, I concluded that it would be extremely difficult to achieve this because the built-in authorization module is not something standalone. It is very tightly integrated with the core, such as api keys and sales channels. So, even if you make your own authentication module, a lot of features that the core provides will no longer work properly. And it will not be possible to fix it adequately without interference in the core of the system. Perhaps I lacked knowledge, but my current conclusions are as follows. Hopefully in the future, the development team will separate the authentication module from the core or add the ability to use their own authentication providers. |
Beta Was this translation helpful? Give feedback.
-
I noticed in a recent merged PR the introduction of a non-overridable middleware (again), but this time for store endpoints (ref) with the introduction of required publishable keys. While I understand the need for this, it might limit the extensibility of the authentication, similarly to the issue described above, when running Medusa as a standalone backend service. Would it be possible to make these middlewares (both the admin authentication as described above, and now the new publishable keys) overridable instead? |
Beta Was this translation helpful? Give feedback.
-
Now with |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I'm currently working on a project that requires me to replace the default admin API authentication in order to authenticate with my own authentication server.
While I've successfully created a custom
authorize()
middleware and applied it to my own routes, I'm also looking to extend its use to the existing admin routes (such as/admin/products
and/admin/orders
).However, I've noticed that my middleware isn't functioning as expected for these admin routes, as they seem to be utilizing the default authentication mechanism. I've explored the authentication opt-out using
export const AUTHENTICATE = false
, but this is only applicable to custom routes and not the built-in ones.Is there a way to achieve this without overriding the 'framework' module? Or is this perhaps an oversight that will be addressed in the future?
Beta Was this translation helpful? Give feedback.
All reactions