Closed kevintechie closed 6 years ago
@kevintechie have you looked at the protocols index? https://github.com/tjwebb/sails-auth/blob/master/api/services/protocols/index.js
Yes. You have to do both, override the protocols require statement and add the new protocol to the project-local protocols/index.js file.
Does anyone have a good workaround for this right now? I'd rather not have to edit files within my node_modules folder for my project.
@kevintechie, can you please explain more detailed, how to override the protocols require statement?
@elennaro,
There's nothing more to overriding the protocols require statement than adding the line I mentioned.
This is needed because the sails-auth module references the protocols directory relative to its local passport.js file. Using the override in your project's passport.js file causes the protocol files to be referenced relative to your project.
-// api/services/passport.js
-'use strict';
-var _ = require('lodash');
-var _super = require('sails-auth/api/services/passport'); // eslint-disable-line no-underscore-dangle, no-inline-comments
-
-function passport() {
-}
-
-passport.prototype = Object.create(_super);
-_.extend(passport.prototype, {
-
- // Extend with custom logic here by adding additional fields and methods,
- // and/or overriding methods in the superclass.
- protocols: require('./protocols')
-
-});
-
-module.exports = new passport(); // eslint-disable-line new-cap, no-inline-comments
@kevintechie Thank you very much! I'll give it a try!
@elennaro Have you gotten this to work?
@pixelbacon It was years ago, I can barely recall... I've binded 'passport-jwt' somehow...
@kevintechie After implementing this, still getting JwtStrategy requires a verify callback
@pixelbacon I'm sorry to say that I've recycled all the brain cells I used for Sails.js long ago. However, it's not clear that your error is related to the issue here. You may want to check #147 for more hints.
When adding support for a new authentication provider and protocol, I discovered that the protocol files created by the generator in/api/services/protocols are ignored by the protocols require statement in the node_modules/sails-auth/api/services/passport.js.
I was able to resolve this by overriding the protocols method by adding the following line to the/api/services/passport.js file:
protocols: require('./protocols')
This changes the path for the require statement to one that's relative to the project rather than relative to the package install location.