@@ -205,6 +205,18 @@ func (s *Service) BatchNewX509SVID(ctx context.Context, req *svidv1.BatchNewX509
205
205
return & svidv1.BatchNewX509SVIDResponse {Results : results }, nil
206
206
}
207
207
208
+ // fetchEntries fetches authorized entries using caller ID from context
209
+ func (s * Service ) isAuthorizedForSPIFFEID (ctx context.Context , entryID string , log logrus.FieldLogger ) (* types.Entry , error ) {
210
+ callerID , ok := rpccontext .CallerID (ctx )
211
+ if ! ok {
212
+ return nil , api .MakeErr (log , codes .Internal , "caller ID missing from request context" , nil )
213
+ }
214
+
215
+ entry := s .ef .IsAuthorizedForEntryID (ctx , callerID , entryID )
216
+ return entry , nil
217
+
218
+ }
219
+
208
220
// fetchEntries fetches authorized entries using caller ID from context
209
221
func (s * Service ) fetchEntries (ctx context.Context , log logrus.FieldLogger ) (map [string ]* types.Entry , error ) {
210
222
callerID , ok := rpccontext .CallerID (ctx )
@@ -350,14 +362,12 @@ func (s *Service) NewJWTSVID(ctx context.Context, req *svidv1.NewJWTSVIDRequest)
350
362
return nil , api .MakeErr (log , status .Code (err ), "rejecting request due to JWT signing request rate limiting" , err )
351
363
}
352
364
353
- // Fetch authorized entries
354
- entriesMap , err := s .fetchEntries (ctx , log )
365
+ entry , err := s .isAuthorizedForSPIFFEID (ctx , req .EntryId , log )
355
366
if err != nil {
356
367
return nil , err
357
368
}
358
369
359
- entry , ok := entriesMap [req .EntryId ]
360
- if ! ok {
370
+ if entry == nil {
361
371
return nil , api .MakeErr (log , codes .NotFound , "entry not found or not authorized" , nil )
362
372
}
363
373
0 commit comments