-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Always clear sessions when user password is updated #3821
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3821 +/- ##
==========================================
- Coverage 90.18% 90.13% -0.06%
==========================================
Files 114 114
Lines 7531 7532 +1
==========================================
- Hits 6792 6789 -3
- Misses 739 743 +4
Continue to review full report at Codecov.
|
}).then((results) => { | ||
expect(results.length).toBe(0); | ||
done(); | ||
}, done.fail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, I've adopted a new pattern in my promise shiz.
I used to do this:
async.do()
.then(done)
.then(null, done.fail)
the reason for the second then
was to prevent an error in the first then block from getting swallowed.
But then I started using bluebird and adopted this:
async.do()
.then(done)
.catch(done.fail)
So testing it out a bit....
const Parse = require('parse/node');
const p = new Parse.Promise((resolve, reject) => {
setTimeout(resolve, 100);
});
p
.then(() => console.log('boo'))
.catch(() => console.error('bingo'));
prints 'boo' as you'd expect. If I then mangle the then
to create an error:
const Parse = require('parse/node');
const p = new Parse.Promise((resolve, reject) => {
setTimeout(resolve, 100);
});
p
.then(() => console.bogusFunction('boo'))
.catch((e) => console.error(e, 'bingo'));
I get:
TypeError: console.bogusFunction is not a function
at ParsePromise.p.then (/Users/arthur/code/followstyle-bot/testing.js:8:23)
at ParsePromise.wrappedResolvedCallback (/Users/arthur/code/followstyle-bot/node_modules/parse/lib/node/ParsePromise.js:153:43)
at ParsePromise.value (/Users/arthur/code/followstyle-bot/node_modules/parse/lib/node/ParsePromise.js:89:36)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5) 'bingo'
so far so good! now to demonstrate why we bother, if i change it to:
const Parse = require('parse/node');
const p = new Parse.Promise((resolve, reject) => {
setTimeout(resolve, 100);
});
p
.then(() => console.bogusFunction('boo'), (e) => console.error(e, 'bingo'));
then it just silently fails! no bueno.
and just to complete the circle, here's how the old style I used worked:
const Parse = require('parse/node');
const p = new Parse.Promise((resolve, reject) => {
setTimeout(resolve, 100);
});
p
.then(() => console.bogusFunction('boo'))
.then(null, (e) => console.error(e, 'bingo'));
which will print out the exact same error as when using the catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's interesting, having last handler like that, me likey :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case it isn't clear, my current preferred is:
async.do()
.then(done)
.catch(done.fail);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@acinader makes sense, do you want me to update the code for that style? Or we'll do it at a later time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to change this. just an fyi :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. i left a long comment on promises though :)
This change caused my users get "invalid session token" error when connecting from different device. |
@MBDeveloper this should only trigger "invalid session token" errors when users update their passwords. |
We add some level of security that change the password dynamically (the details are not relevant) and since we change the password it invalidate the user token on the other device. |
@MBDeveloper this was a security issue, when the password was reset by a masterKey, the sessions were not invalidated. You should be thankful some people report those issues and make the platform more secure. If this doesn't fit your use case, feel free to fork the project. |
Can you please direct me to the location of the change in the sources so I can submit a pull request that add a flag to override the default behaviour. |
the location of the change is the PR itself... Not sure what more you need. And as mentioned, this is a security issue and I won't budge on this behaviour. |
Hello @flovilmart , There is (or was?) a parameter called revokeSessionOnPasswordReset: true/false when initializing Parse Server
Is it still taken into account or does the v2.4.1 ignores it? Thanks! |
@Helmikku the flag should be still taken into account as properly covered by tests :) |
No description provided.