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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cad071c
Add _users DB callbacks when opening _users shards
mikewallace1979 2ed6938
Update auth DB docs via the auth module
mikewallace1979 6266b95
Move admin ddoc check for _users DB to http layer
mikewallace1979 4e24b4c
Whitespace
mikewallace1979 633b7f1
[squash] Move users DB check into its own fun
mikewallace1979 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,30 +116,37 @@ create(DbName, Options0) -> | |
delete(DbName, Options) -> | ||
gen_server:call(couch_server, {delete, DbName, Options}, infinity). | ||
|
||
is_users_db(DbName) -> | ||
IsUsersDbPreds = [ | ||
fun() -> DbName == config:get("couch_httpd_auth", "authentication_db", "_users") end, | ||
fun() -> path_ends_with(DbName, <<"_users">>) end, | ||
fun() -> binary_to_list(mem3:dbname(DbName)) == config:get("chttpd_auth", "authentication_db", "_users") end | ||
], | ||
lists:any(fun(F) -> F() end, IsUsersDbPreds). | ||
|
||
maybe_add_sys_db_callbacks(DbName, Options) when is_binary(DbName) -> | ||
maybe_add_sys_db_callbacks(?b2l(DbName), Options); | ||
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">>), | ||
IsUsersDb = DbName ==config:get("couch_httpd_auth", "authentication_db", "_users") orelse | ||
path_ends_with(DbName, <<"_users">>), | ||
path_ends_with(DbName, <<"_replicator">>), | ||
IsUsersDb = is_users_db(DbName), | ||
if | ||
DbName == DbsDbName -> | ||
[sys_db | Options]; | ||
DbName == NodesDbName -> | ||
[sys_db | Options]; | ||
IsReplicatorDb -> | ||
[{before_doc_update, fun couch_replicator_manager:before_doc_update/2}, | ||
{after_doc_read, fun couch_replicator_manager:after_doc_read/2}, | ||
sys_db | Options]; | ||
IsUsersDb -> | ||
[{before_doc_update, fun couch_users_db:before_doc_update/2}, | ||
{after_doc_read, fun couch_users_db:after_doc_read/2}, | ||
sys_db | Options]; | ||
true -> | ||
Options | ||
DbName == DbsDbName -> | ||
[sys_db | Options]; | ||
DbName == NodesDbName -> | ||
[sys_db | Options]; | ||
IsReplicatorDb -> | ||
[{before_doc_update, fun couch_replicator_manager:before_doc_update/2}, | ||
{after_doc_read, fun couch_replicator_manager:after_doc_read/2}, | ||
sys_db | Options]; | ||
IsUsersDb -> | ||
[{before_doc_update, fun couch_users_db:before_doc_update/2}, | ||
{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 commentThe reason will be displayed to describe this comment to others. Learn more. Ixnay on the whitespace only changes. |
||
end. | ||
|
||
path_ends_with(Path, Suffix) -> | ||
|
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
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.
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?