This repository has been archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Add users db security rules on clustered interface #20
Open
mikewallace1979
wants to merge
5
commits into
master
Choose a base branch
from
2452-users-db-security-on-clustered-interface
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add users db security rules on clustered interface #20
mikewallace1979
wants to merge
5
commits into
master
from
2452-users-db-security-on-clustered-interface
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The check to determine whether to add the callback functions for _users DB operations was only checking the raw database name. When using the authentication DB on the clustered database this meant that this check would fail and the callbacks would not be added. This commit checks the DB name (rather than the shard name) against the value of chttpd_auth/authentication_db so that shards for clustered authentication DBs have the appropriate callbacks added. COUCHDB-2452 1/3
Documents in the authentication DB were being updated directly from couch_httpd_auth via couch_db:update_doc/3. This meant that updates to documents with the authentication DB on the clustered interface (5984) would fail. This commit makes the auth module responsible for the document update via a ?MODULE:update_auth_doc/1 function and add couch_auth_cache:update_auth_doc/1 which proxies to couch_db:update_doc/3. COUCHDB-2452 2/3
In order to restrict access to design documents in the authentication DB to admins only we were checking whether a user was admin in the couch_server callback. When running the auth DB on the clustered interface this meant that admins could not read the design doc because the user context was not being passed to any of the calls to open the design doc. One possible fix is to add the user context to all the clustering code involving design doc access however given the amount of plumbing here is fairly substantial the chances of getting it wrong are rather high. The alternative is to move this check into the http layer where we already have access to the user context. This commit moves the admin check when accessing design docs in the auth DB into couch_httpd_db (for the admin port). A separate commit in couchdb-chttpd adds a similar check for requests through the clustered port. COUCHDB-2452 3/3
@@ -122,24 +122,26 @@ maybe_add_sys_db_callbacks(DbName, Options) -> | |||
DbsDbName = config:get("mem3", "shard_db", "dbs"), | |||
NodesDbName = config:get("mem3", "shard_db", "nodes"), | |||
IsReplicatorDb = DbName == config:get("replicator", "db", "_replicator") orelse | |||
path_ends_with(DbName, <<"_replicator">>), | |||
path_ends_with(DbName, <<"_replicator">>), |
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.
_replicator
db seems have the same issue right?
LGFM, though long chains of orelse leaves some strange feeling about, but no idea how to make them better. |
I did cringe a little when adding the second orelse but also couldn't come up with an alternative (other than an even-more-unwieldy nested case statement). |
The chain of orelse statements combined with the indentation was pretty hard to read. This commit moves the checks into their own function and uses lists:any (which also shortcircuits).
{after_doc_read, fun couch_users_db:after_doc_read/2}, | ||
sys_db | Options]; | ||
true -> | ||
Options |
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.
Ixnay on the whitespace only changes.
I haven't done a thorough review yet, but this seems related to PR #41 |
janl
pushed a commit
to janl/couchdb-couch
that referenced
this pull request
Nov 28, 2015
Matching couch_mrview, set view_type to "map" before validating query parameters for _all_docs. This fixes a bug whereby validation fails when specifying _all_docs?conflicts=true. This closes apache#20 COUCHDB-2523 Signed-off-by: Alexander Shorin <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Apply authentication_db security rules when authentication_db is on the clustered interface (5984).
COUCHDB-2452