-
Notifications
You must be signed in to change notification settings - Fork 61
Adding configurable audience property for flyte clients #329
Conversation
6537f7a
to
3643093
Compare
Codecov Report
@@ Coverage Diff @@
## master #329 +/- ##
==========================================
+ Coverage 73.12% 75.94% +2.82%
==========================================
Files 18 18
Lines 1362 1185 -177
==========================================
- Hits 996 900 -96
+ Misses 315 234 -81
Partials 51 51
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -45,16 +50,21 @@ func NewTokenSourceProvider(ctx context.Context, cfg *Config, tokenCache cache.T | |||
tokenURL = metadata.TokenEndpoint | |||
} | |||
|
|||
clientMetadata, err := authClient.GetPublicClientConfig(ctx, &service.PublicClientAuthConfigRequest{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we only fetch this if the cfg.Audience
is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done., if either scopes or Audience is empty then we call this api
982443b
to
fbc0faa
Compare
18b3904
to
956c7a2
Compare
clientMetadata, err := authClient.GetPublicClientConfig(ctx, &service.PublicClientAuthConfigRequest{}) | ||
audienceValue := cfg.Audience | ||
|
||
if len(scopes) == 0 || len(audienceValue) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm understanding correctly with this change now we'll always make the call to get the public client config even in the case where the audience property is not actually required? (It isn't always required, right - this is just custom for some deployments?)
Is there anyway to indicate we want to explicitly fetch the audience property so that end users don't have to now update their deployments with a dummy config value for the audience property to avoid this lookup even when scopes are set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done Added added new config flag useAudienceFromAdmin
which will force pull config from Admin only if its set otherwise it wont call the publicEndpoint config
Also added tests for the number of invocattions to the public admin endpoint
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
… config. Default is false and expects clients to pass it Signed-off-by: pmahindrakar-oss <[email protected]>
956c7a2
to
cf832ba
Compare
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
* Adding configurable audience property for flyte clients Signed-off-by: pmahindrakar-oss <[email protected]> * changed the const audience to audienceKey Signed-off-by: pmahindrakar-oss <[email protected]> * fixed unit tests Signed-off-by: pmahindrakar-oss <[email protected]> * fixed unit test Signed-off-by: pmahindrakar-oss <[email protected]> * nit Signed-off-by: pmahindrakar-oss <[email protected]> * feedback Signed-off-by: pmahindrakar-oss <[email protected]> * refactored unit tests Signed-off-by: pmahindrakar-oss <[email protected]> * Added UseAudienceFromAdmin property to force pull audience from admin config. Default is false and expects clients to pass it Signed-off-by: pmahindrakar-oss <[email protected]> * Added test for expected number of calls to the public admin endpoint Signed-off-by: pmahindrakar-oss <[email protected]> * fixed the tests Signed-off-by: pmahindrakar-oss <[email protected]> Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss [email protected]
TL;DR
Most Authorization server provide a way to use default audience which can be used to request auth tokens which is what flyte relied on before this PR.
The current PR allows to send a configurable audience field when requesting auth token from the authorization server.
Follow up PR to return audience also from PublicClientConfig endpoint of flyteadmin
flyteorg/flyteadmin#485
If client config contains the audience field then that would be used
Though if the override to useAudienceFromAdmin is set then whatever audience is set in admin would be used
Type
Are all requirements met?
Complete description
How did you fix the bug, make the feature etc. Link to any design docs etc
Tracking Issue
flyteorg/flyte#2959
Follow-up issue
NA