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

Fix #838 Implement readOnly to CBLSyncListener #867

Merged
merged 2 commits into from Aug 15, 2015

Conversation

pasin
Copy link
Contributor

@pasin pasin commented Aug 14, 2015

  • Added OnSyncAccessCheckBlock property to CBLSyncConnection similarly to CBL_Router.OnAccessCheckBlock property. OnSyncAccessCheckBlock (if specified) will be called to check the access for each sync request coming to the CBLSyncConnection's handlers. The handlers will then return the corresponding error responses depending on the result of the OnSyncAccessCheckBlock call.
  • In read only mode, CBLSyncListener will block access to setCheckpoint, changes, and rev requests.
    Implement readOnly mode in CBLSyncListener #838

@pasin pasin changed the title Implement readOnly to CBLSyncListener (#838) Fix #838 Implement readOnly to CBLSyncListener Aug 14, 2015
CBLStatus status = self.onSyncAccessCheck(request, docID);
if (CBLStatusIsError(status)) {
NSString* message;
[request respondWithErrorCode: CBLStatusToHTTPStatus(status, &message)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a race condition: it's not guaranteed that CBLStatusToHTTPStatus will have been called before the message parameter is pushed on the stack. You'll need to break the function call out and put it above this line.

- Added OnSyncAccessCheckBlock property to CBLSyncConnection similarly to CBL_Router.OnAccessCheckBlock property. OnSyncAccessCheckBlock (if specified) will be called to check the access for each sync request coming to the CBLSyncConnection's handlers. The handlers will then return the corresponding error responses depending on the result of the OnSyncAccessCheckBlock call.

- In read only mode, CBLSyncListener will block access to setCheckpoint, changes, and rev requests.

#838
@pasin pasin force-pushed the feature/issue_838_synclistener_readonly branch from 2e8f708 to 6fd7e8a Compare August 15, 2015 00:07
@snej
Copy link
Contributor

snej commented Aug 15, 2015

I have docID there so that (#726) if we allow users to grant access via the listener delegate, the users can use doc ids for in their logic.

That makes sense. We can optimize this by adding the docID as a property of the request so that it's quicker to get it. (And then we have to make sure that it matches the docID parsed from the JSON, in case the peer tries to cheat...)

snej added a commit that referenced this pull request Aug 15, 2015
…_readonly

Fix #838 Implement readOnly to CBLSyncListener
@snej snej merged commit d486504 into master Aug 15, 2015
@snej snej deleted the feature/issue_838_synclistener_readonly branch August 15, 2015 00:15
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.

None yet

2 participants