-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FetchJWTSVIDs and SubscribeToJWTBundles #2789
Add FetchJWTSVIDs and SubscribeToJWTBundles #2789
Conversation
Signed-off-by: Yuhan Li <[email protected]>
Signed-off-by: Yuhan Li <[email protected]>
} | ||
var spiffeIDs []spiffeid.ID | ||
|
||
log = log.WithField(telemetry.Registered, true) |
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.
Looks like registered is set to false if spiffeIDs is empty, but errors from matching identities (278l) will have Registered = true.
May we set Registered = true, only if spiffeIDs != 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.
I temporarily removed the Registered ID, and I looked at the description in telemetry. It is more like whether the caller is authenticated
func (s *Service) SubscribeToJWTBundles(req *delegatedidentityv1.SubscribeToJWTBundlesRequest, stream delegatedidentityv1.DelegatedIdentity_SubscribeToJWTBundlesServer) error { | ||
ctx := stream.Context() | ||
log := rpccontext.Logger(ctx) | ||
cachedSelectors, err := s.isCallerAuthorized(ctx, log, nil) |
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.
move cachedSelectors together to error verification
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.
I'm not sure if your comment is
var cachedSelectors []*common.Selector
if cachedSelectors, err: = s.is CallerAuthorized (ctx, log, nil); err! = nil {return err}
I looked at the spire code and did not recommend such an implementation. Are you sure we need this?
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.
sorry for the confusion... it is basically put error verification together with line where error is returned,
for example:
ctx := stream.Context()
log := rpccontext.Logger(ctx)
cachedSelectors, err := s.isCallerAuthorized(ctx, log, nil)
if err != nil {
return err
}
it is generally written this way to simplify reading
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.
😯 I do pay little attention to this matter, it has been completed now.
managerErr error | ||
expectTokenIDs []spiffeid.ID | ||
}{ | ||
{ |
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.
can you add a test case for invalid selectors?
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.
good point
@@ -441,6 +646,16 @@ func (m *FakeManager) SubscribeToCacheChanges(selectors cache.Selectors) cache.S | |||
return newFakeSubscriber(m, m.updates) | |||
} | |||
|
|||
func (m *FakeManager) FetchJWTSVID(ctx context.Context, spiffeID spiffeid.ID, audience []string) (*client.JWTSVID, error) { | |||
svid := m.ca.CreateJWTSVID(spiffeID, audience) | |||
if m.err != nil { |
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.
Can you move error validation to the first line? (you are not validating generated SVID, if error is not nil)
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
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.
Thanks for this contribution @loveyana!
This is looking great. Could you please update the dependency of spire-api-sdk
to point to the latest commit of next
branch? That should clean the PR of build errors.
Signed-off-by: Yuhan Li <[email protected]>
Signed-off-by: Yuhan Li <[email protected]>
Signed-off-by: Yuhan Li <[email protected]>
…/spire into add-delegated-subscribe-jwt-api Signed-off-by: Yuhan Li <[email protected]>
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.
LGTM!!!
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.
Thank you @loveyana!
Signed-off-by: Yuhan Li [email protected]
Pull Request check list
Affected functionality
Delegated Identity API
Description of change
Add FetchJWTSVIDs and SubscribeToJWTBundles in Delegated Identity API.
Which issue this PR fixes
#2788