Skip to content

Vault - Token mode is not renewed #529

Description

@Dugong42

I'm using vault.auth.method=Token to authenticate with Vault, but I've observed that token renewal does not work.

PR #344 introduced token renewal for AppRole, which tries to renew when the initial AuthResult has a TTL > 0.

if (result.ttl().isPresent() && result.ttl().get() > 0) {
log.debug("ctor() - AuthResult does have a ttl - scheduling token renewal.");
executorService.scheduleAtFixedRate(() -> authenticateVault(config, vaultConfig),
0, result.ttl().get() - (result.ttl().get() / 10), TimeUnit.SECONDS);
} else {
log.debug("ctor() - AuthResult does not have a ttl so not scheduling token refresh.");
}

The scheduled task triggers authentication, which works for AppRole.
However this implementation currently does not work with the Token method.

For the Token method, authentication only calls auth/token/lookup-self, which does not renew. It should also call auth/token/renew-self.

static class Token extends AuthHandler {
@Override
public AuthMethod method() {
return AuthMethod.Token;
}
@Override
public AuthResult execute(VaultConfigProviderConfig config, Vault vault) throws VaultException {
LookupResponse lookupResponse = vault.auth().lookupSelf();
return result(lookupResponse);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions