Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit authentication for emitting messages but not for listening #567

Closed
knappdev opened this issue May 3, 2017 · 6 comments
Closed

Comments

@knappdev
Copy link

knappdev commented May 3, 2017

Steps to reproduce

REST API works with one time authentication. But socket needs authentication everytime

import socketio from 'feathers-socketio/client';

this.app = feathers()
.configure(socketio(socket))
.configure(hooks())
.configure(authentication({
storage: AsyncStorage // To store our accessToken
}));
app.io.emit('messages::create', {
"text": "I really have to iron"
}, (error, message) => {
console.log('Todo created', message);
});

emit results in no output as socket is not explicitly authenticated

Expected behavior

we can listen to server message without explicit authentication. shouldn't the behaviour be same for both emitting and listening to messages

Actual behavior

console.: Todo created undefined

React Native Version:0.43.4

@daffl
Copy link
Member

daffl commented May 4, 2017

If you console.log(error) instead of the message you will see that you get the not authenticated error.

This is exactly the same call that the client service using this.app.service('messages').create({ text }).then(message => {}).catch(error => {}) does internally (it just converts the callback into a Promise).

@knappdev
Copy link
Author

knappdev commented May 4, 2017

@daffl I agree. As you said I am getting Not Authenticated error. But the issue I want to point out is that why we can receive messages without authenticating the socket?

@marshallswain
Copy link
Member

marshallswain commented May 4, 2017

Because you need to filter messages on the server. There are so many different types of auth implementations that it's kinda impossible to provide a basic setup out of the box.

https://docs.feathersjs.com/api/events.html#event-filtering

@knappdev
Copy link
Author

knappdev commented May 5, 2017

@marshallswain thanks for pointing that out. Then this behavior is as per implementation.

@daffl
Copy link
Member

daffl commented May 9, 2017

As @marshallswain pointed out, you have to explicitly add event filtering. We are working on improving this (see #388 (comment)) but for now this is indeed how it is intended. Going to close this issue.

@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants