#admin-jwt

1 messages · Page 1 of 1 (latest)

grand geyser
#

unknown authentication strategy admin-jwt

#

any idea why this pops up

#

using medusa 1.7

normal wadi
#

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 🙂

grand geyser
#

thanks..will do

grand geyser
#

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

grand geyser
#

worked around the issue

brave wraith
#

@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

grand geyser
#

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

brave wraith
#

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

grand geyser
#

Is this because the auth route is admin/auth

#

or am I missing something

brave wraith
#

When you try to override it?

grand geyser
#

it looks like the original Middleware is kicking in, but not finding the original passport strategy

brave wraith
#

But are you trying to override the admin-jwt strategy? What are you trying to do?

grand geyser
#

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

brave wraith
#

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

grand geyser
#

I think you are right

#

I had merged your pr earlier

#

the auth strategy one

brave wraith
#

And you are using the local version of the package ?

brave wraith
#

Cause i don’t see the one you are referring to

grand geyser
brave wraith
#

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

grand geyser
#

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

brave wraith
#

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

GitHub

The open-source Shopify alternative ⚡️. Contribute to medusajs/medusa development by creating an account on GitHub.

#

Then to start your server you run node --preserve-symlinks ./index.js

grand geyser
#

thanks

brave wraith
#

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

grand geyser
#

thanks

#

thanks

grand geyser
#

fixed the admin jwt issue

#

thanks for your help

grand geyser
#

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

brave wraith
#

Is that a strategy from the auth plugin?

grand geyser
#

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

brave wraith
#

What do you mean, can you share your middleware please?

#

I ll have a look as soon as i can

brave wraith
#

I will also probably need to see your strategy, i am waiting for juan to update his pr since they are some changes required

grand geyser
#

ah ok

grand geyser
#

so managed to get it to work

#

apparently I did need the call back route

brave wraith
#

Yes this is the one that create the token and assign it