在SpringVault中,当数据库凭据通过hashicorpVault以静态角色类型轮换时,是否可以获取事件

发布于 2025-01-10 15:01:46 字数 912 浏览 1 评论 0原文

我正在使用 SpringVault 从 hashcorpVault 获取数据库凭据。使用 SecretLeaseContainer 和 LeaseListener 我能够在凭证为动态机密轮换时获取事件。以下是我获取动态凭证事件的代码,

SecretLeaseContainer container = new SecretLeaseContainer(getVaultTemplate());        
container.requestRotatingSecret("database/creds/dynamicRole");
container.addLeaseListener(vaultListener);
container.afterPropertiesSet();
container.start();
    
@Override
public void onLeaseEvent(SecretLeaseEvent secretLeaseEvent)
{
    if (secretLeaseEvent instanceof SecretLeaseCreatedEvent) {
       System.out.println("Secrets created: " + ((SecretLeaseCreatedEvent) secretLeaseEvent).getSecrets());
    }

    if (secretLeaseEvent instanceof SecretLeaseRotatedEvent) {
       System.out.println("Secrets rotated: " + ((SecretLeaseRotatedEvent) secretLeaseEvent).getSecrets());
    }
}

以同样的方式,当数据库凭证以静态角色类型旋转时,我尝试获取事件,但它不起作用。当数据库凭据以静态角色类型轮换时是否可以获取事件?我需要做什么才能获得事件?

I'm using Spring vault to fetch the database credentials from hashicorp vault. Using SecretLeaseContainer and LeaseListener i'm able to get the events when the credentials are rotated for Dynamic secrets. Following is my code to get the events for dynamic credentials

SecretLeaseContainer container = new SecretLeaseContainer(getVaultTemplate());        
container.requestRotatingSecret("database/creds/dynamicRole");
container.addLeaseListener(vaultListener);
container.afterPropertiesSet();
container.start();
    
@Override
public void onLeaseEvent(SecretLeaseEvent secretLeaseEvent)
{
    if (secretLeaseEvent instanceof SecretLeaseCreatedEvent) {
       System.out.println("Secrets created: " + ((SecretLeaseCreatedEvent) secretLeaseEvent).getSecrets());
    }

    if (secretLeaseEvent instanceof SecretLeaseRotatedEvent) {
       System.out.println("Secrets rotated: " + ((SecretLeaseRotatedEvent) secretLeaseEvent).getSecrets());
    }
}

In the same way i tried to get the events when database credeantials are roatated with static role type, but its not working. Is it possible to get events when the database credentials are rotated with static role type? What should i need to do to get events?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文