You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
Hey guys, I have asked this question in Slack but didn't get a reply so I decided to write here.
I have the following situation. I am trying to add anonymous authentication in my application: Backend - FeathersJS and Frontend - React Native.
I need to have local + anonymous auth, local will be used to give an access to admins and anonymous will be used to give an access for regular users. Admins and regular users will have two different apps.
So when I am trying to get anonymous JWT in RN app using this line this.app.authenticate({ strategy: 'jwt' }), it gives me an error: error: authentication - Method: create: No auth token, as I understand I get this error because I have this line authentication.hooks.authenticate(config.strategies) in authentication.js in before-create hook on the server. But when I remove this line, everything works fine on the client and I get JWT.
So what I do now is I change this line this.app.authenticate({ strategy: 'jwt' }) —> this.app.authenticate({ strategy: 'jwt', anonymous: true }) on the client and change authentication.hooks.authenticate(config.strategies) —>
While your solution would definitely work, I think the "right" way would be to create feathers-authentication-anonymous as a plugin wrapped around passport-anonymous.
@kanzitelli check out the plugin generator if you haven't, yet. It will handle the heavy lifting of all of the package overhead. I believe it's built into the feathers-cli.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Steps to reproduce
Hey guys, I have asked this question in Slack but didn't get a reply so I decided to write here.
I have the following situation. I am trying to add anonymous authentication in my application: Backend - FeathersJS and Frontend - React Native.
I need to have
local
+anonymous
auth,local
will be used to give an access to admins andanonymous
will be used to give an access for regular users. Admins and regular users will have two different apps.So when I am trying to get anonymous JWT in RN app using this line
this.app.authenticate({ strategy: 'jwt' })
, it gives me an error:error: authentication - Method: create: No auth token
, as I understand I get this error because I have this lineauthentication.hooks.authenticate(config.strategies)
inauthentication.js
inbefore-create
hook on the server. But when I remove this line, everything works fine on the client and I get JWT.So what I do now is I change this line
this.app.authenticate({ strategy: 'jwt' })
—>this.app.authenticate({ strategy: 'jwt', anonymous: true })
on the client and changeauthentication.hooks.authenticate(config.strategies)
—>on the server and when I do it everything works fine.
My question is if this is the right solution? Or maybe I miss something and it should be implemented other way? Is this a secure solution?
Tell us about the applicable parts of your setup.
NodeJS version: 7.10.0
React Native Version: 0.46.1
The text was updated successfully, but these errors were encountered: