[dotnet] Expand code with Interfaces and DI-configurations options #7403
Replies: 1 comment 2 replies
-
Hi @Dragonsangel thank you so much for your interest in our .NET SDK. We currently have a private repo with a library I helped make that integrates secrets manager secrets with I do have concerns about adding interfaces to all the classes though, the problem is we plan on adding lots of new methods and features to those classes. It's considered a breaking change to add new methods to an interface but it's not a breaking change to add them to a class. What is a somewhat common thing to do is to make your own interface wrapping the specific feature you use and instead injecting that throughout your own application. We do on our own |
Beta Was this translation helpful? Give feedback.
-
Code Contribution Proposal
Heya,
I have had a look at using the dotnet SDK for use in my personal and potential corporate environments.
The implementation that you so far build is elegantly simple and easy to use and I have been able to integrate my personal SM into my projects. Thanks for that.
I would like to help in expanding the implementation to support dependency injection and unit testing by creating interfaces and create service collection extensions to register and configure the BW Client at application startup, including reading settings either from the appsettings.json-Files, environment variables or a combination of them.
My idea here would be to have a
IBitwardenClient
-Interface that one can register at startup with awebApplicationBuild.Services.AddBitwarden(BitwardenSettings bitwardenSettings, String accessToken)
-method. This method would store theaccessToken
in a private Property in a singleton instance ofBitwardenClient
.The method
BitwardenClient.AccessTokenLogin()
will only be called in the moment the first request to the API is called. Alternatively, we can have awebApplication.UseBitwarden()
that forces a call toAccessTokenLogin()
.The implementations for
ProjectsClient
andSecretsClient
can also be abstracted with interfaces to allow for easier unit testing of implementations.I had a look at the roadmap and current feature requests and currently it seems there are no plans for the above mentioned.
Would this be a good change and expansion?
Beta Was this translation helpful? Give feedback.
All reactions