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 was archived by the owner on Mar 22, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 22, 2022. It is now read-only.
Feature Request: Anonymous Authentication Strategy Support #423
Many systems require an additional anonymous authentication strategy (over and above the existing local, jwt) for fresh customers landing on the website.
It might seem oxymoronic to authorize someone anonymously, but it makes a lot more sense to not freely open multiple endpoints and resources a user might need to touch and only provide a single entry point from where one can auth anonymously and then use the provided token (which could have things like session expiry, etc) to further deal with the system.
According to my explorations here: #411 currently this works out of the box for a rest client, but not for an io client.
A sub-request is to document this feature along with an example that has two auth strategies being used simultaneously, anonymous for fresh customers and local for internal team members.
@daffl I've read through #411 which leads over to this issue.
I'm confused. At the end of #411@ekryski suggests opening a new issue for anonymous authentication support.
This issue is immediately opened and then closed quickly - 4 days later. Is that because the feature (anonymous authentication) was implemented or did you know something that @ekryski didn't?
As I said, v1.x of feathers-authentication allows to create anonymous JWTs (as @ekryski said in #411) out of the box. Just add a beforecreate hook to /authentication that sets hook.data.payload to what you need in the JWT payload.
So I'm presently seeing the same issues as the poster in #411 - anonymous authentication works in REST, but fails in Socket.IO even if you're using a completely separate service.
Here's the output of the frames I'm seeing in the web socket debug tab in chrome:
What it looks like is that the server is first responding with a NotAuthenticated error, then it tries to return the actual token however the client is only seeing the Error message, and the "catch" section of the Promise is being called.
Code I'm using to authenticate - see the remove function below (Angular2 frontend, so this is Typescript):
On thing you can do to get everything via socket.io is calling app.service('authentication').create().then(jwt) on the client and then authenticating with the jwt strategy using the token you get back.
I think the problem is that the Socket authentication tries to use a passport strategy. Maybe the fallback should be to call authentication.create instead of throwing an error. Would you mind creating an issue for this?
Activity
daffl commentedon Feb 25, 2017
The latest v1.0.0 allows to create anonymous JWT by default. Upgrading to v1.0.0 will allow the functionality you seem to be looking for.
mmucklo commentedon Mar 21, 2017
@daffl I've read through #411 which leads over to this issue.
I'm confused. At the end of #411 @ekryski suggests opening a new issue for anonymous authentication support.
This issue is immediately opened and then closed quickly - 4 days later. Is that because the feature (anonymous authentication) was implemented or did you know something that @ekryski didn't?
daffl commentedon Mar 21, 2017
As I said, v1.x of feathers-authentication allows to create anonymous JWTs (as @ekryski said in #411) out of the box. Just add a
beforecreatehook to/authenticationthat setshook.data.payloadto what you need in the JWT payload.mmucklo commentedon Mar 21, 2017
Ok, thanks for the quick response! I'm going to continue to give things a shot.
mmucklo commentedon Mar 21, 2017
So I'm presently seeing the same issues as the poster in #411 - anonymous authentication works in REST, but fails in Socket.IO even if you're using a completely separate service.
Here's the output of the frames I'm seeing in the web socket debug tab in chrome:
What it looks like is that the server is first responding with a NotAuthenticated error, then it tries to return the actual token however the client is only seeing the Error message, and the "catch" section of the Promise is being called.
Code I'm using to authenticate - see the remove function below (Angular2 frontend, so this is Typescript):
this._socketApp is set to the feathers() client (which has had authentication setup as follows)
Here's what shows up in the client:
mmucklo commentedon Mar 21, 2017
Update:
After combing around documentation on the web and reading about socket-jwt, I tried a different approach that seems to work.
daffl commentedon Mar 21, 2017
On thing you can do to get everything via socket.io is calling
app.service('authentication').create().then(jwt)on the client and then authenticating with thejwtstrategy using the token you get back.I think the problem is that the Socket authentication tries to use a passport strategy. Maybe the fallback should be to call
authentication.createinstead of throwing an error. Would you mind creating an issue for this?ekryski commentedon Mar 22, 2017
It might actually be related to the same thing that @marshallswain created #455 for.