#admin-jwt
1 messages · Page 1 of 1 (latest)
Can I get you to file an issue in our repository and share more details e.g. reproducible steps? Would allow us to help you 🙂
thanks..will do
the issue is with the plugin medusa-plugin-auth, it doesnt add to the strategies of the api middleware
only admin-jwt and bearer exist
other methods are ignored
worked around the issue
@grand geyser the auth plugin does not touch the core strategies anymore. What version are you on? Basically the jwt is added to the session like the core does. So it would be nice to open an issue if something is going on
I needed to over ride the core strategy as I am using a proprietary authentication that issues its own jwt
if there is a way I can do it without over riding the core strategy I am all for it
Yes there is, you can look at the auth plugin, they generate a jwt assigned to the session for the core to retrieve it with the internal strategies and avoid overriding anything in order to not messed up something or miss an update
I keep getting an error unknown strategy admin-jwt
Is this because the auth route is admin/auth
or am I missing something
When you try to override it?
it looks like the original Middleware is kicking in, but not finding the original passport strategy
But are you trying to override the admin-jwt strategy? What are you trying to do?
create single sign on
I am not over riding it
but that is easier
but that will break the current implementation of the auth plugin
The thing is that if you are not overriding it there is no reason for it to be unknown. Which is why i am asking ahah not for you to override it
On the other hand, the passport instance need to be the same as the one used by the core, which is why i am asking if you are doing that in your backend or in a plugin. Just need the info to help you out
For example the auth plugin does not install passport in order to use the same peer. If you use another passport instance, the strategies will not be where you think they are ahah
But your error looks a lot like you have two different passport installed
And you are using the local version of the package ?
Can you link me the pr you merged please
Cause i don’t see the one you are referring to
for testing
For my testing backend i have a custom entry point and i start it using the preserve symlinks flag. So when i yarn link the package, the peer deps are preserved and use the one from the backend
It avoids the kind of issues you are facing
hmm let me try it. do you yarn link to the dist or the src folder
or the package root
I haven't done that before
You can only link from where the package.json is located. So you go to the medusa-plugin-auth dir and you run yarn link, then in your backend you run yarn link medusa-plugin-auth. It will create a symlink which means each time you re build the package, you just need to restart your server. For the custom entry file you create an index.js file in your backend root directory and you can put the content that you can find here https://github.com/medusajs/medusa/blob/master/packages/medusa/src/commands/start.js you just need the start function and then immediately call it after. You have to replace the variables, directory become process.cwd() and port become the port is the 9000
Then to start your server you run node --preserve-symlinks ./index.js
thanks
Now, each time you want to link a local packages and you run this command, the peer deps will be resolved from the current node module instead of the one from your package in order to avoid dev deps and when you make changes to the plugin and build it, you can just restart the server
just curious now I am getting a 401 authentication error when I tried the authentication path..the path is admin/auth/mycustomauth
the verification returns a medusa user
but the jwt helper isn't called
Is that a strategy from the auth plugin?
yup
followed the auth0
also have submitted a small pr
I am using the market place middleware
so have explicitly set all non auth route to auth necessary
and auth get to auth not necessary
I did this by writing @middleware twice over the same class
will this work
?
one for auth routes and once for non auth routes
What do you mean, can you share your middleware please?
I ll have a look as soon as i can
To create your own? Or to create a new one in the plugin repo?
I will also probably need to see your strategy, i am waiting for juan to update his pr since they are some changes required
ah ok
Yes this is the one that create the token and assign it