trailsjs / sails-permissions

Comprehensive user permissions and entitlements system for sails.js and Waterline. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.
MIT License
418 stars 113 forks source link

api.services.protocols can never be customised #10

Open airtonix opened 9 years ago

airtonix commented 9 years ago

myproject/api/services/protocols/index


var _ = require('lodash');
var _super = require('sails-permissions/api/services/protocols');

_.merge(exports, _super);
_.merge(exports, {
    local: require('./local'),
    jwt: require('./jwt'),
    email: require('./email')
});

myproject/api/services/protocols/passport


...

  loadStrategies: function() {
        var self = this,
            strategies = sails.config.passport,
            baseUrl = sails.getBaseurl();

        sails.log.silly("this.protocols: ", _.keys(this.protocols))

        Object.keys(strategies).forEach(function(key) {
...

results in:

silly: this.protocols [ 'local', 'basic', 'oauth', 'oauth2', 'openid' ]
tjwebb commented 9 years ago

Hmm, I don't know why this would be. I'll try to reproduce.

tjwebb commented 9 years ago

Did you ever work around this?

tjwebb commented 9 years ago

Ah, I think my generated index.js file there is misleading. You can't extend that object from there. Just add those directly to sails.services.protocols and that will work.

finalherizo commented 9 years ago

Hi,

I know I'm too late, but perhaps one way to extend it would be to require the local protocols in your extended passport.js myproject/api/services/protocols/passport protocols: require('./protocols'). I'm still too early in my project and I don't know if that will really work but at least that give me all my custom protocols.