Assert that shards have the same security object
diff --git a/src/couchdb_peruser.erl b/src/couchdb_peruser.erl
index 2abb56c..370be31 100644
--- a/src/couchdb_peruser.erl
+++ b/src/couchdb_peruser.erl
@@ -125,11 +125,11 @@
 
 ensure_security(User, UserDb) ->
     {ok, Shards} = fabric_db_meta:get_all_security(UserDb, [admin_ctx()]),
-    % We assume that all shards have the same security object, and
-    % therefore just pick the first one.
     {_ShardInfo, {SecProps}} = hd(Shards),
+    % assert that shards have the same security object
+    true = lists:all(fun(Shard) -> {_, {SecProps}} =:= Shard end, Shards),
     case lists:foldl(
-           fun (Prop, SAcc) -> add_user(User, Prop, SAcc) end,
+           fun(Prop, SAcc) -> add_user(User, Prop, SAcc) end,
            {false, SecProps},
            [<<"admins">>, <<"members">>]) of
         {false, _} ->