Skip to content

Parameters of session:false not work #152

@jcyh0120

Description

@jcyh0120

I tried this example code passport-local-example and applied parameters to local strategy.

//express-4.x-local-example/server.js
passport.use(new LocalStrategy({
  usernameField: 'email',
  passwordField: 'passwd',
  passReqToCallback: true,
  session: false
}, function(req, username, password, done) {
  // request object is now first argument
  // ...
  }));

However, it seems that session is still in use. I could get user's password from req.session.user.

Only username , password, callback are set in this lib.

//passport-local/lib/strategy.js
function Strategy(options, verify) {
  if (typeof options == 'function') {
    verify = options;
    options = {};
  }
  if (!verify) { throw new TypeError('LocalStrategy requires a verify callback'); }
  
  this._usernameField = options.usernameField || 'username';
  this._passwordField = options.passwordField || 'password';
  
  passport.Strategy.call(this);
  this.name = 'local';
  this._verify = verify;
  this._passReqToCallback = options.passReqToCallback;
}

I don't have experience in security. Is it correct that I could get user's password in req.user.password?
Will this be unsafe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions