Snowflake:允许用户更改其 RSA_PUBLIC_KEY 属性

Kri*_*ian 4 snowflake-cloud-data-platform

我的 Snowflake 用户具有 SYSADMIN 角色;但是,我希望能够自己更改 RSA_PUBLIC_KEY 和 RSA_PUBLIC_KEY_2 属性。是否可以创建角色和权限的组合来允许用户仅修改其 RSA_PUBLIC_KEY 和 RSA_PUBLIC_KEY_2 属性?

wal*_*nte 6

这些不是用户可以自行更改的属性之一: https://docs.snowflake.net/manuals/sql-reference/sql/alter-user.html

更具体地说,需要 securityadmin (或 accountadmin)角色:https://docs.snowflake.net/manuals/user-guide/security-access-control-overview.html

还在这里讨论: https://snowflakecommunity.force.com/s/question/0D50Z00009Q8cYtSAJ/createalter-user

* 更新 *

作为解决方法,创建一个由 SECURITYADMIN 角色拥有的存储过程,并在定义中使用 EXECUTE AS OWNER 选项,并向您的用户授予访问权限:

use role securityadmin;

create or replace procedure p_set_rsa_key_for_user_x(RSA_KEY string) 
returns text
language javascript
execute as owner
as
  $$
  const stmt = snowflake.createStatement({ 
    sqlText: "alter user user_x set RSA_PUBLIC_KEY = ?",
    binds: [RSA_KEY] 
  })
  const rs = stmt.execute()
  return 'SUCCESS'
  $$
;

grant usage on procedure p_set_rsa_key_for_user_x(string) to role analyst;

use role analyst;

call p_set_rsa_key_for_user_x('MIIBIjANBgkqh...');
Run Code Online (Sandbox Code Playgroud)

其中“user_x”是相关用户名,“analyst”是他们被授予的角色。

希望这有帮助...