dapr / go-sdk

Dapr SDK for go
Apache License 2.0
442 stars 170 forks source link

refactor setting of api token #502

Closed famarting closed 6 months ago

famarting commented 6 months ago

Description

This PR refactors the way the API Token is handled, now instead of having to manually set to token in the context by using withAuthToken there are two interceptors that will set the token automatically.

This new approach will guarantee that every new function added to the client will automatically make use of the api token if its set, unlike the current approach, where actually there were a few functions that were not using withAuthToken and therefore wouldn't work properly if the api token was set...

Another example of the benefits and the need of this refactor is the use of the grpc connection that is being made in this PR https://github.com/dapr/go-sdk/pull/487 , since for workflows the grpc connection is used directly and we won't control the calls made by that durabletask grpc client we need to transparently set the api token i.e with the interceptors I added

Issue reference

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

codecov[bot] commented 6 months ago

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (a65edda) 70.26% compared to head (476a3f2) 70.11%.

Files Patch % Lines
client/client.go 59.52% 15 Missing and 2 partials :warning:
client/actor.go 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #502 +/- ## ========================================== - Coverage 70.26% 70.11% -0.16% ========================================== Files 35 35 Lines 2859 2884 +25 ========================================== + Hits 2009 2022 +13 - Misses 738 748 +10 - Partials 112 114 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

famarting commented 6 months ago

Should I be able to explicitly pass a custom token?

that was already possible, and still will be, with the function WithAuthToken