keycloak-authorization-services-dotnet
keycloak-authorization-services-dotnet copied to clipboard
Refit Dependency
Currently it is very difficult, if not impossible, to make certain configurations of the HttpClient
instance.
For starters you have no control over the construction of the HttpClient
object so you cannot pass it an instance of HttpClientHandler
to be able to configure for example a proxy or other things.
https://github.com/NikiforovAll/keycloak-authorization-services-dotnet/blob/6d20ce592c224ffb32c7a3e198e9d26cef8dc5ba/src/Keycloak.AuthServices.Sdk/Admin/ServiceCollectionExtensions.cs#L46
I think that at the very least there should be an overload that allows you to pass an instance of HttpClient directly: Func<IServiceProvider, HttpClient> clientProvider
. It is very common nowadays this pattern: https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
Another issue is why there is a hard dependency to Refit when it should not be necessary, the implementation should be cleaner without dependencies to Refit.
Whoever uses the library if they want to use Refit should be their choice but not an imposition.
If you agree I am willing to help with a PR.
Ok, I see that the AddKeycloakAdminHttpClient
method returns an IHttpClientBuilder
and I see that the Refit.HttpClientFactory
dependency uses the Microsoft library I said.
Even so, I still think that the Refit dependency should not be necessary.
Examining the code I see that it provides several functionalities through C# attributes for client generation and I understand the "convenience" of using it but I still think that it should be a library for the exclusive use of the consumer of a library, not intended for whoever develops a library because you are imposing that use.
Good point, next version will focus on removing unnecessary dependencies
Will be fixed as part of: #64
Done as part of https://github.com/NikiforovAll/keycloak-authorization-services-dotnet/releases/tag/2.0.0