Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No salt value stored in mongodb collection!. #96

Closed
akuznetsov-gridgain opened this issue Aug 26, 2015 · 8 comments
Closed

No salt value stored in mongodb collection!. #96

akuznetsov-gridgain opened this issue Aug 26, 2015 · 8 comments

Comments

@akuznetsov-gridgain
Copy link

After upgrading to 1.0.2 I got:

Connection closed: 401 - Authentication failed: Authentication not possible. No salt value stored in mongodb collection!

Workaround: use 1.0.1

Seems that smth was broked between 1.0.1 & 1.0.2

@GastonFerrari
Copy link

Similar issue here, salt and hash are actually stored in mongodb but mongoose doesn't fetch the values because they're not in the schema.

@ChrisHubinger
Copy link
Contributor

I'm working on a fix for that (at the moment writing a test to cover this issue) without selecting those fields per default (=fetch then from MongoDB during authenticate when not available yet).

The cause is that the salt & hash fields are defined with "select: false" and therefore the model fetched by mongoose does no longer contain the fields for comparison.

Tricky thing is that the tests do not cover this issue because in the tests the user instance gets created and the authentication is run against the in-memory object (which contains the fields from the setPassword call in setup) and not a clean fetched user instance from MongoDB.

ChrisHubinger added a commit to ChrisHubinger/passport-local-mongoose that referenced this issue Aug 28, 2015
@saintedlama
Copy link
Owner

Manually reverted the pull request in question. Released 1.2.0

@ChrisHubinger
Copy link
Contributor

+1
should i finish my solution with loading the required fields in the authentication method when not available? Could send you the PR in the next few hours if you like...
IMHO not loading the salt & hash is real important issue as it is just too easy (and actually lots of n00bs just do it) that people simply return the loaded model as it is back to the client e.g. leaking their secrets...

The need to hit the database in "authenticate" is in relation to the security implications more then acceptable.

@saintedlama
Copy link
Owner

👍

saintedlama added a commit that referenced this issue Sep 14, 2015
@BrandonCopley
Copy link

3.0.0 seems to solve this.

@akuznetsov-gridgain
Copy link
Author

I think this issue could be closed. Should I close this issue? or @saintedlama should do this?

@saintedlama
Copy link
Owner

Thanks for reminding me to close the issue 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants