rajanadar / VaultSharp

A comprehensive cross-platform .NET Library for HashiCorp's Vault, a secret management tool
http://rajanadar.github.io/VaultSharp
Apache License 2.0
488 stars 130 forks source link

Create `Secret`, base class of `Secret<T>` #310

Closed giggio closed 1 week ago

giggio commented 1 year ago

Describe the feature request or question Create Secret, base class of Secret<T> (it could also be an interface). It would contain everything Secret<T> has, but the public TData Data { get; set; } property.

Link to the Vault API Docs that support this feature N/A

Additional context There is currently no way to abstract over different Secret<T>s. For example, when one creates a credential, you get a Secret<UsernamePasswordCredentials>, when you renew it, you get a Secret<RenewedLease>, and we need to create different references, with no way to abstract over them. With an abstract base classe of Secret we could do that.

giggio commented 1 year ago

I could send a PR if that would help.

rajanadar commented 1 year ago

Can you please explain why you need abstractions over that class? The library gives you whatever instances/types you need. What references are you creating?

giggio commented 1 year ago

After creating the issue I worked over the abstraction I needed, and it is actually a base lease interface. I created as a record, but it is copying data because of the lack of an abstracting in this library. You can see it here: https://github.com/giggio-samples/vault-k8s-sample/blob/main/src/VaultApi/BaseLease.cs And it being used here: https://github.com/giggio-samples/vault-k8s-sample/blob/fad7340a339b6ced0764bf59912d9609552f6bb0/src/VaultApi/VaultClientFactory.cs#L32 And here: https://github.com/giggio-samples/vault-k8s-sample/blob/fad7340a339b6ced0764bf59912d9609552f6bb0/src/VaultApi/VaultClientFactory.cs#L54 And here: https://github.com/giggio-samples/vault-k8s-sample/blob/fad7340a339b6ced0764bf59912d9609552f6bb0/src/VaultApi/MongoClientFactory.cs#L45

rajanadar commented 1 week ago

@giggio the intent is to not have a untyped abstraction. It is error prone. Cast Exception etc. Let me know, if you are missing anything concrete.