jopenlibs / vault-java-driver

Zero-dependency Java client for HashiCorp's Vault
https://jopenlibs.github.io/vault-java-driver
27 stars 18 forks source link

[BUG] unwrap response without auth #3

Closed tledkov closed 1 year ago

tledkov commented 1 year ago

Error stacktrace:

com.bettercloud.vault.VaultException: java.lang.UnsupportedOperationException: Not an object: null
at com.bettercloud.vault.api.Auth.unwrap([Auth.java:1586](http://auth.java:1586/))
at com.bettercloud.vault.api.Auth.unwrap([Auth.java:1506](http://auth.java:1506/))
at ru.sbrf.kafka.config.provider.secman.SecretReader.login([SecretReader.java:82](http://secretreader.java:82/))

Caused by: java.lang.UnsupportedOperationException: Not an object: null
at com.bettercloud.vault.json.JsonValue.asObject([JsonValue.java:144](http://jsonvalue.java:144/))
at com.bettercloud.vault.response.AuthResponse.<init>([AuthResponse.java:41](http://authresponse.java:41/))

Example request to Vault by HashiCorp

curl --location --request POST 'http://127.0.0.1:8200/v1/sys/wrapping/unwrap' \
--header 'X-Vault-Token: s.JqBHMFEyIQy1i2tIisfXfYrI' \
--header 'Content-Type: application/json' \
--data-raw '{
  "token": "s.Z4UQgIfiDsqIwELuIInamXEl"
}':

Response:

{
    "request_id": "ccf41e8c-cab1-4b2c-d2c6-9faf81fb526c",
    "lease_id": "",
    "renewable": false,
    "lease_duration": 0,
    "data": {
        "foo": "bar",
        "zip": "zap"
    },
    "wrap_info": null,
    "warnings": null,
    "auth": null
}
tledkov commented 1 year ago

Fixed by PR #4