trailsjs / sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
https://www.npmjs.org/package/sails-auth
MIT License
265 stars 141 forks source link

Using a custom strategy? #108

Open shaunc opened 8 years ago

shaunc commented 8 years ago

I would like to use https://github.com/leftmostcat/passport-oauth2-password-grant, customizing to provide my own userProfile(). In config/passport.js I have:

var PasswordGrantStrategy = require('passport-oauth2-password-grant');
var inherits = require('util').inherits;

function CraneGrantStrategy() {
  PasswordGrantStrategy.apply(this, arguments);
  ...
}
inherits(CraneGrantStrategy, PasswordGrantStrategy);

module.exports.passport = {
  crane: {
    name: 'crane',
    protocol: 'oauth2',
    strategy: CraneGrantStrategy,
    options: {
      tokenURL: '/oauth2/token',
      clientID: XWEAVER_CLIENT_ID
    }
  },
 ...
}

It would seem that the option protocol: 'oauth2' provides a verify() method, but what if I want to provide my own verify method? (And what are protocols anyway? Is there a tutorial anywhere or some notes to provide more details as to how the pieces fit together?)

fenichelar commented 8 years ago

Did you ever figure this out? I am trying to do the same thing with CAS.