当前位置: 首页 > 知识库问答 >
问题:

Hashicorp Vaultsharp权限拒绝错误

平俊茂
2023-03-14

误差

System.Exception:存储库配置失败:出现一个或多个错误。({“errors”:[“1错误发生:\n\t*权限被拒绝\n\n”]})在VaultConnection.vaultTextensions.addVaultKeys.getValutKeyValuePairs(IConfiguration buildConfig)C:\users\48013\source\repos\sample\vault1\vaultConnection\vaultTextensions\addVaultKeys.cs:vaultConnection.startup.ConfigureReservices(IServiceCollection services)

摘要

使用AppRoleAuthMethodInfo方法从Hashicorp存储库读取键值会导致拒绝Me-Permission错误。下面提到的一小段代码来描述这个问题。

下面是代码片段:

IAuthMethodInfo authMethod = new AppRoleAuthMethodInfo(buildConfig["vault:roleid"], buildConfig["vault:secretid"]);

var VaultClientSettings = new VaultClientSettings(buildConfig["vault:address"], authMethod);

IVaultClient vaultClient = new VaultClient(VaultClientSettings);

 // Token Apis.
var callingTokenInfo = vaultClient.V1.Auth.Token.LookupSelfAsync().Result;

var vaultSecrets = vaultClient.V1.Secrets.KeyValue.V1
                        .ReadSecretAsync(buildConfig["vault:path"])
                        .Result.Data;

---> It throws error at this point and failed to execute the above line var vaultSecrets = vaultClient.V1.Secrets.KeyValue.V1.........

1. vault secrets enable -path=devkv kv
2. vault kv put devkv/connection timeout=120 source=DATA
3. vault policy write sqlconnection sqlconnection.hcl
4. Output of the policy created: - vault policy read sqlconnection

路径“devkv/appid*”{capabilitions=[“create”,“read”,“update”,“delete”,“list”]}

5. vault auth enable approle
6.  vault write auth/approle/role/sqlconnectionrole policies=default,sqlconnection
7. vault read auth/approle/role/sqlconnectionrole/role-id
8. vault write -f auth/approle/role/sqlconnectionrole/secret-id

If I test this through a command line, I am able to access the keys
9. vault write auth/approle/login role_id="1a5aa9a5-9d79-5743-de-9dca0433dc77" secret_id="138ec92b-02c8-610d-109b-3f325e29be"


步骤9执行的命令的输出

Received a token from this command. Login with this token to check whether or not keys associated with sqlconnection role can be read and I was successfully able to read the value.
> PS C:\WINDOWS\system32> vault write auth/approle/login role_id="1a5aa9a5-9d79-5743-3cde-9dca0433dc77" secret_id="138ec92b-02c8-610d-109b-3f325e29bef0"
> Key                     Value
> ---                     -----
> token                   s.g5NfR7DJLSD9hp1amXCvp92I
> token_accessor          u5raQKxARuAjluywS1SatFuy
> token_duration          768h
> token_renewable         true
> token_policies          ["default" "sqlconnection"]
> identity_policies       []
> policies                ["default" "sqlconnection"]
> token_meta_role_name    sqlconnectionrole
> PS C:\WINDOWS\system32> vault login s.g5NfR7DJLSD9hp1amXCvp92I
> WARNING! The VAULT_TOKEN environment variable is set! This takes precedence
> over the value set by this command. To use the value set by this command,
> unset the VAULT_TOKEN environment variable or set it to the token displayed
> below.
> 
> Success! You are now authenticated. The token information displayed below
> is already stored in the token helper. You do NOT need to run "vault login"
> again. Future Vault requests will automatically use this token.
> 
> Key                     Value
> ---                     -----
> token                   s.g5NfR7DJLSD9hp1amXCvp92I
> token_accessor          u5raQKxARuAjluywS1SatFuy
> token_duration          767h59m35s
> token_renewable         true
> token_policies          ["default" "sqlconnection"]
> identity_policies       []
> policies                ["default" "sqlconnection"]
> token_meta_role_name    sqlconnectionrole
> 
> PS C:\WINDOWS\system32> vault kv get devkv/connection
> ===== Data =====
> Key        Value
> source     DATA
> timeout    120

>

共有1个答案

陆俊迈
2023-03-14

您的挂载点与键路径混杂在一起。将它们分开如下:

var vaultSecrets = vaultClient.V1.Secrets.KeyValue.V1
   .ReadSecretAsync("connection", "devkv").Result.Data;           

 类似资料:
  • 问题内容: 我运行 npm install lodash, 但它抛出 错误:EACCES:权限被拒绝 错误。我知道这是权限问题,但据我所知,本地安装节点模块不需要sudo权限。如果我使用sudo运行它,它将安装在〜/ node_modules文件夹中。 drwxrwxr-x 是现有文件夹的文件许可权。我不知道可能出了什么问题。 下面是错误消息。 问题答案: 使用 npm init 创建 packa

  • 我运行npm install lodash,但它抛出错误:EACCES:权限被拒绝错误。我知道这是权限问题,但据我所知,在本地安装节点模块不需要sudo权限。如果我用sudo运行它,它会安装在~/node\u modules文件夹中。drwxrwxr-x是现有文件夹的文件权限。我不知道可能出了什么问题。 下面是错误消息。

  • 我在django admin(127.0.0.1:8000/admin)中尝试为用户添加个人资料照片时收到此错误消息 有人能帮我找出原因吗? OSError at /admin/role/role/6/[Errno 13]权限被拒绝:'/User'请求方法: POST请求URL:http://127.0.0.1:8000/admin/role/role/6/Django版本: 1.8.2异常类型:

  • 我在Ruby 2.0.0-p353和OSX Mavericks上使用Rails 4.0.2、Guard 2.2.4、Guard rspec 4.2.4、rspec Rails 2.14.0、Capybara 2.2.1和Poltergeist 1.5.0。 当我运行bundle exec Guard时,我得到了很多失败的错误消息:一个错误发生在后钩子Errno::EACCES:权限拒绝- /usr

  • 问题内容: 我最近使用CentOS 6.3将Go安装到了我们的服务器上。安装似乎一切正常。但是,我制作了一个测试“ hello world”脚本,运行时得到以下输出。 现在运行go env或其他go命令似乎可以正常工作。起初,我认为这是一个权限问题,但是以root用户身份运行时,我会得到相同的结果。一个 问题答案: 只是猜测:出于安全原因,您的nix可能会禁用在/ tmp中执行程序。它可能在Cen