1

我正在用sqlitezumero构建一个移动应用程序。

我注册了托管服务器并阅读了有关 auth 数据库和 ACL 的 zumero 文档。据我了解,其中有一个包含用户和加密密码的身份验证数据库,默认情况下,服务器配置为不允许将该数据库同步到本地设备。

我想在我的应用中显示用户列表。似乎我可以更改 ACL,以便可以将身份验证数据库下拉到设备,但这似乎是个坏主意。在不影响安全性的情况下,将用户数据下载到设备的推荐方法是什么?

4

1 回答 1

2

首先,让我们指出,如果您愿意,您可以启用身份验证数据库的同步。

Zumero 内部身份验证数据库中的密码使用 bcrypt 加密。如果将 auth db 拉到移动设备上,确实会带来安全风险,因为现在有人可以破解东西,获取加密密码并尝试解密它们。但额外的风险并不大。密码仍然是加密的。

要启用内部身份验证 dbfile,您需要做两件事:

  1. 当您创建它时(使用 zumero_internal_auth_create),您必须指定函数的最后两个参数来描述允许谁添加 ACL 条目。例如,要允许 zumero_users_admin 的成员更改身份验证数据库上的 ACL 条目,请执行以下操作:

    SELECT zumero_internal_auth_create(
    server_url,
    dbfile,
    credentials_scheme,
    credentials_username,
    credentials_password,
    first_username,
    first_password,
    allow_add_scheme,
    allow_add_who,
    zumero_internal_auth_scheme('zumero_users_admin'),
    zumero_named_constant('acl_who_any_authenticated_user')
    );
    
  2. 使用 zumero_internal_auth_set_acl_entry 添加拉取功能:

    SELECT zumero_internal_auth_set_acl_entry(
    server_url,
    dbfile,
    credentials_scheme,
    credentials_user,
    credentials_password,
    scheme,
    who,
    tbl,
    zumero_named_constant('acl_op_pull'),
    zumero_named_constant('acl_result_allow'),
    );
    

请注意,您可以限制 WHO 允许拉动。另请注意,授予提取身份验证数据库的能力并不授予任何以其他方式修改它的能力。

好的,回到问题:

另一种选择是拥有两个内部身份验证数据库,一个带有密码,一个除了别名之外什么都没有。现在,您可以使用别名启用同步,从而允许您的移动应用程序拥有用户列表,而无需访问密码。

破解 bcrypt 字符串很难,但如果你没有字符串,那就更难了。:-)

要以这种方式进行设置,您需要使用 zumero_internal_auth_create() 创建两个身份验证数据库。每次添加用户时,都需要添加两次。一次在密码数据库中使用 zumero_internal_auth_add_user(),一次在别名数据库中使用 zumero_internal_auth_add_alias()。

    SELECT zumero_internal_auth_create(
    server_url,
    'passwords',
    credentials_scheme,
    credentials_username,
    credentials_password,
    first_username,
    first_password,
    zumero_internal_auth_scheme('zumero_users_admin'),
    zumero_named_constant('acl_who_any_authenticated_user'),
    zumero_internal_auth_scheme('zumero_users_admin'),
    zumero_named_constant('acl_who_any_authenticated_user')
    );

    SELECT zumero_internal_auth_create(
    server_url,
    'aliases',
    credentials_scheme,
    credentials_username,
    credentials_password,
    first_username,
    first_password,
    zumero_internal_auth_scheme('zumero_users_admin'),
    zumero_named_constant('acl_who_any_authenticated_user'),
    zumero_internal_auth_scheme('zumero_users_admin'),
    zumero_named_constant('acl_who_any_authenticated_user')
    );

    SELECT zumero_internal_auth_set_acl_entry(
    server_url,
    'aliases',
    credentials_scheme,
    credentials_user,
    credentials_password,
    scheme,
    who,
    tbl,
    zumero_named_constant('acl_op_pull'),
    zumero_named_constant('acl_result_allow'),
    );

    SELECT zumero_internal_auth_add_user(
    server_url,
    'passwords',
    credentials_scheme,
    credentials_username,
    credentials_password,
    'gandalf',
    'thegrey'
    );

    SELECT zumero_internal_auth_add_alias(
    server_url,
    'aliases',
    credentials_scheme,
    credentials_username,
    credentials_password,
    'gandalf',
    'passwords',
    'gandalf'
    );
于 2013-05-07T20:46:10.177 回答