From fee157d2b2f8431e2465c93af397197dd2f2d6ea Mon Sep 17 00:00:00 2001 From: L2JE Date: Mon, 28 Nov 2022 16:56:59 -0300 Subject: [PATCH] Consider token num uses on lookup and show localized message on loginByAppRole exception. --- .../valfadeev/rundeck/plugin/vault/VaultClientProvider.java | 3 +-- .../valfadeev/rundeck/plugin/vault/VaultStoragePlugin.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultClientProvider.java b/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultClientProvider.java index c1e3994..537b0a0 100644 --- a/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultClientProvider.java +++ b/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultClientProvider.java @@ -182,8 +182,7 @@ private String getVaultAuthToken() throws ConfigurationException, VaultException } catch (VaultException e) { throw new ConfigurationException( - String.format("Encountered error while authenticating with %s", - vaultAuthBackend) + String.format("Encountered error while authenticating with %s: %s", vaultAuthBackend, e.getLocalizedMessage()) ); } break; diff --git a/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultStoragePlugin.java b/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultStoragePlugin.java index bb097ea..d25d2f4 100644 --- a/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultStoragePlugin.java +++ b/src/main/java/io/github/valfadeev/rundeck/plugin/vault/VaultStoragePlugin.java @@ -269,8 +269,8 @@ private boolean isDir(String key) { protected void lookup(){ try { - long ttl = getVaultClient().auth().lookupSelf().getTTL(); - if (ttl <= guaranteedTokenValidity) { + LookupResponse lookupSelf = getVaultClient().auth().lookupSelf(); + if (lookupSelf.getTTL() <= guaranteedTokenValidity || lookupSelf.getNumUses() < 0) { loginVault(clientProvider); } } catch (VaultException e) {