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.
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'
});
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 : https://github.com/jaredhanson/passport/issues/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.