Skip to content

Adds support for readOnly masterKey #787

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

Merged
merged 6 commits into from
Oct 26, 2017
Merged

Adds support for readOnly masterKey #787

merged 6 commits into from
Oct 26, 2017

Conversation

flovilmart
Copy link
Contributor

No description provided.

@@ -77,7 +77,7 @@ module.exports = function(config, options) {
// Serve the configuration.
app.get('/parse-dashboard-config.json', function(req, res) {
let response = {
apps: config.apps,
apps: [...config.apps], // make a copy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat trick.

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome and we'll use it for sure.

As usual, I have a bunch of nits that you can take or leave ;). it's just how I read.


if (successfulAuth) {
if (appsUserHasAccess) {
// Restric access to apps defined in user dictionary
// If they didn't supply any app id, user will access all apps
response.apps = response.apps.filter(function (app) {
return appsUserHasAccess.find(appUserHasAccess => {
return app.appId == appUserHasAccess.appId
const isSame = app.appId == appUserHasAccess.appId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer === :). i know its not yours....

@@ -81,6 +81,7 @@ function initialize(app, options) {
function authenticate(userToTest, usernameOnly) {
var appsUserHasAccessTo = null;
var matchingUsername = null;
var isReadOnly = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch all these to let? your call :)....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep good call

@@ -96,12 +97,14 @@ function authenticate(userToTest, usernameOnly) {
matchingUsername = user.user;
// User restricted apps
appsUserHasAccessTo = user.apps || null;
isReadOnly = user.readOnly;
}

return isAuthenticated;
}) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ewww, remove the ? true: false? as completely redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap

}

return isAuthenticated;
}) ? true : false;
}) ? true : false ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mistake?

Copy link
Contributor Author

@flovilmart flovilmart Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no because of the && && it was returning an object instead of true / false, and was breaking some tests.

README.md Outdated

### Making an app read-only for all users

Start your parse server with
Copy link
Contributor

@acinader acinader Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse-server for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also could put readOnlyMasterKey masterKey insteaxc of masterKey....i.e. mark as code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes
!

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. doc is clear.

@flovilmart flovilmart merged commit 67d3c97 into master Oct 26, 2017
@flovilmart flovilmart deleted the read-only-masterKey branch October 26, 2017 18:50
flovilmart added a commit that referenced this pull request Oct 27, 2017
* Adds support for readOnly masterKey

* nits

* Adds tests for readOnly

* Updates documentation

* nit

* nits
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

Successfully merging this pull request may close these issues.

2 participants