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

authentication of channels / streams with passport.js #21

Open
AdrianRossouw opened this issue Jul 31, 2015 · 0 comments
Open

authentication of channels / streams with passport.js #21

AdrianRossouw opened this issue Jul 31, 2015 · 0 comments

Comments

@AdrianRossouw
Copy link
Contributor

I was just thinking about how it would be possible to have a channel that requires you to provide certain credentials before messages to pass. It also occured to me that it might be possible to adapt passport.js to do this.

Passport seems to be designed with stuff like this in mind : jaredhanson/passport#383

For instance, this bit of pseudocode would be to allow file uploads, but only for messages that authenticate against the passport local auth, or twitter, or json web token. whatever.

var graft = require('graft');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var passportStream = require('passport-stream')(passport);
var fs = require('fs');

passport.use(new LocalStrategy(/* snip */));

var graftServer = graft()
  .pipe(passportStream.authenticate('local'))
  .pipe(uploadService)

// client
var graftClient = graft();
graftClient.pipe(graftServer);

graft.write({ 
  username: 'adam',
  password: '***',
  file: fs.createReadStream('/file/to/upload'),
  location: '/path/on/server'
});
@AdrianRossouw AdrianRossouw changed the title authentication authentication of channels / streams with passport.js Jul 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant