sakurity / securelogin

This version won't be maintained!
MIT License
1.22k stars 35 forks source link

Help with Node #8

Open AlexGustafsson opened 7 years ago

AlexGustafsson commented 7 years ago

I could start offer some help with the NodeJS implementation in about a week from now. Is there any known implementation already or has anyone started to work on it?

homakov commented 7 years ago

No, no one is working on Node now, and it's great if you can help. I can contact you in a week (messenger?) and we will do a generic node.js integration and maybe some plugins for popular passport.js?

andrewda commented 7 years ago

I would also love to help out with a Node implementation!

andrewda commented 7 years ago

Posted this on the Slack but I'll post it here too for visibility:

Here's a minimal Node.js SecureLogin module: https://github.com/andrewda/node-securelogin And here's a Passport/Express module: https://github.com/andrewda/passport-securelogin

I would love some help with these!

AlexGustafsson commented 7 years ago

Would you feel comfortable in posting issues regarding what you want done with some tag "help-needed" or the like?

andrewda commented 7 years ago

Sure, I'll look over and see what still needs to be done in a bit.

homakov commented 7 years ago

I wonder what's best way to implement cred rotation endpoint /securelogin? Should it be copy pasted by every app or just baked in npm module? If it's baked in then we need a common way to interact with user db to find user by pubkey and then replace it. Is there some common interface/ORM?

andrewda commented 7 years ago

I made something in passport-securelogin that handles mostly everything for the /securelogin endpoint (see https://github.com/andrewda/passport-securelogin#profile-change). I eventually want it to be more baked in so developers don't have to worry about it as much.

andrewda commented 7 years ago

For example, I eventually want to refactor the entire module to look something like this:

const sl = new SecureLogin({
  origins: ['localhost:3001', 'http://c.dev'],
  changeCredentials: (err, newUser, oldPublicKey) => {
    if (err) {
      console.log(err);
    } else {
      // do database stuff to update the user
    }
  }
});

// now you can access all SecureLogin methods through `sl`

passport.use(new sl.Strategy({ domains: 'http://c.dev:3001' }));

app.post('/login', passport.authenticate('securelogin', { session: true }),
  (req, res) => res.sendStatus(200));

app.post('/sendmoney', sl.ScopeMiddleware({ domains: 'http://c.dev:3001' }),
  (req, res) => {
    console.log(`${req.user.authkeys.public} -> $${req.securelogin.scope.amount} -> ${req.securelogin.scope.address}`);
    res.json(req.securelogin.scope);
  });