Skip to content

Commit 11cde12

Browse files
authored
Merge pull request #3497 from acinader/allow-empty-client-key
Allow empty client key
2 parents 5a22df1 + 5861996 commit 11cde12

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

spec/Middlewares.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ describe('middlewares', () => {
7979
});
8080
});
8181

82+
it('should succeed when client key supplied but empty', (done) => {
83+
AppCache.put(fakeReq.body._ApplicationId, {
84+
clientKey: '',
85+
masterKey: 'masterKey',
86+
restAPIKey: 'restAPIKey'
87+
});
88+
fakeReq.headers['x-parse-client-key'] = '';
89+
middlewares.handleParseHeaders(fakeReq, fakeRes, () => {
90+
expect(fakeRes.status).not.toHaveBeenCalled();
91+
done();
92+
});
93+
});
94+
8295
it('should succeed when no keys are configured and none supplied', (done) => {
8396
AppCache.put(fakeReq.body._ApplicationId, {
8497
masterKey: 'masterKey'

src/middlewares.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ export function handleParseHeaders(req, res, next) {
122122
// to preserve original behavior.
123123
const keys = ["clientKey", "javascriptKey", "dotNetKey", "restAPIKey"];
124124
const oneKeyConfigured = keys.some(function(key) {
125-
return req.config[key];
125+
return req.config[key] !== undefined;
126126
});
127127
const oneKeyMatches = keys.some(function(key){
128-
return req.config[key] && info[key] == req.config[key];
128+
return req.config[key] !== undefined && info[key] === req.config[key];
129129
});
130130

131131
if (oneKeyConfigured && !oneKeyMatches) {

0 commit comments

Comments
 (0)