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

Replication + ACLs #1202

Closed
wants to merge 1 commit into from
Closed

Replication + ACLs #1202

wants to merge 1 commit into from

Conversation

ritch
Copy link
Member

@ritch ritch commented Mar 11, 2015

This is a fix for: #1166

Connect to #1166

@bajtos This test already passes. I must be missing something. Are you suggesting that we check before we start replicating?

Also can you comment on the tests I've added. I'd like to ensure I've got those right before I move much further.


test.serverApp = loopback();
test.serverApp.use(function(req, res, next) {
console.log(req.method, req.url);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps use debug logs here? require('debug')('test')('%s %s', req.method, req.url)

@bajtos
Copy link
Member

bajtos commented Mar 12, 2015

This test already passes. I must be missing something.

I don't know enough about our auth&auth implementation to be able to help you. Few things that stand out in the current code:

  • You are calling app.enableAuth() for all tests, even for the test that verifies anonymous mode
  • The restrictive ACLs are enabled after the application and the model was already set up. Is that valid approach, I mean will the auth code pick up these changes?

I don't know how to help you here without debugging your new tests, which is something you can do yourself too.

Are you suggesting that we check before we start replicating?

I am not following you here, what should we check before we start?

Also can you comment on the tests I've added. I'd like to ensure I've got those right before I move much further.

Yes, it looks good so far. Few more scenarios to consider:

  • a happy path where replication succeeds for a logged-in user
  • replication is rejected for a logged-in user due to permissions

It may be a good idea to test all three operations in all three scenarios: create, update, delete.

On more idea to consider: bulkUpdate should be as atomic as possible. If any of the updates is rejected by auth, then no updates should be applied at all.

@bajtos
Copy link
Member

bajtos commented Mar 12, 2015

This test already passes. I must be missing something.

I think the test is passing because the ACL implementation reject anonymous requests when there are ACL configured for the operation, thus I guess this is mostly expected.

A more interesting scenario is described in my comment above, where the user is authenticated, but they don't have permissions to create/update/delete the specific model instance.

The built-in User model is a good example:

  • regular users cannot create new User instances (accounts)
  • a regular user can edit only his own account
  • a regular user can either delete only his own account or cannot delete any account at all

I am not sure how exactly the current implementation works, please take the above items with a grain of salt.

@ritch
Copy link
Member Author

ritch commented Mar 12, 2015

I don't know how to help you here without debugging your new tests, which is something you can do yourself too.

I am more concerned with what exactly led you to create #1166.

@bajtos
Copy link
Member

bajtos commented Mar 12, 2015

As discussed in chat, I didn't have any specific case where it should not work, just that we didn't have any tests and I had a feeling that a the current implementation of authentication may not work, because:

  • auth is implemented as a beforeRemote, thus it verifies permissions at the granularity of a single method (bulkUpdate in this case)
  • bulkUpdate makes possibly multiple create/update/delete calls, however these calls don't go through the authentication layer

What I would like to see is a suite of tests that will show that bulkUpdate respects permissions like I described in my comment above, i.e.g that when a user "Joe" can read all Products but cannot modify any of them, then a bulk update will reject a request containing updates of Product instances. When "Employee" record is viewable by all users but only owner can edit it, then a bulk update containing update of different employee than the logged in user will fail.

@ritch ritch added #sprint67 and removed #review labels Mar 25, 2015
@bajtos bajtos assigned bajtos and unassigned ritch Apr 2, 2015
@bajtos
Copy link
Member

bajtos commented Apr 3, 2015

Closing in favour of #1270

@bajtos bajtos closed this Apr 3, 2015
@bajtos bajtos removed the #wip label Apr 3, 2015
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.

4 participants