@@ -391,14 +391,12 @@ func (s *Service) GetAuthorizedEntries(ctx context.Context, req *entryv1.GetAuth
391
391
return nil , err
392
392
}
393
393
394
- for i , entry := range entries {
395
- applyMask (entry , req .OutputMask )
396
- entries [i ] = entry
397
- }
394
+ resp := & entryv1.GetAuthorizedEntriesResponse {}
398
395
399
- resp := & entryv1. GetAuthorizedEntriesResponse {
400
- Entries : entries ,
396
+ for _ , entry := range entries {
397
+ resp . Entries = append ( resp . Entries , entry . Clone ( req . OutputMask ))
401
398
}
399
+
402
400
rpccontext .AuditRPC (ctx )
403
401
404
402
return resp , nil
@@ -424,7 +422,7 @@ func (s *Service) SyncAuthorizedEntries(stream entryv1.Entry_SyncAuthorizedEntri
424
422
return SyncAuthorizedEntries (stream , entries , s .entryPageSize )
425
423
}
426
424
427
- func SyncAuthorizedEntries (stream entryv1.Entry_SyncAuthorizedEntriesServer , entries []* types. Entry , entryPageSize int ) (err error ) {
425
+ func SyncAuthorizedEntries (stream entryv1.Entry_SyncAuthorizedEntriesServer , entries []api. ReadOnlyEntry , entryPageSize int ) (err error ) {
428
426
// Receive the initial request with the output mask.
429
427
req , err := stream .Recv ()
430
428
if err != nil {
@@ -447,18 +445,17 @@ func SyncAuthorizedEntries(stream entryv1.Entry_SyncAuthorizedEntriesServer, ent
447
445
448
446
// Apply output mask to entries. The output mask field will be
449
447
// intentionally ignored on subsequent requests.
450
- for i , entry := range entries {
451
- applyMask (entry , req .OutputMask )
452
- entries [i ] = entry
453
- }
448
+ initialOutputMask := req .OutputMask
454
449
455
450
// If the number of entries is less than or equal to the entry page size,
456
451
// then just send the full list back. Otherwise, we'll send a sparse list
457
452
// and then stream back full entries as requested.
458
453
if len (entries ) <= entryPageSize {
459
- return stream .Send (& entryv1.SyncAuthorizedEntriesResponse {
460
- Entries : entries ,
461
- })
454
+ resp := & entryv1.SyncAuthorizedEntriesResponse {}
455
+ for _ , entry := range entries {
456
+ resp .Entries = append (resp .Entries , entry .Clone (initialOutputMask ))
457
+ }
458
+ return stream .Send (resp )
462
459
}
463
460
464
461
// Prepopulate the entry page used in the response with empty entry structs.
@@ -475,9 +472,9 @@ func SyncAuthorizedEntries(stream entryv1.Entry_SyncAuthorizedEntriesServer, ent
475
472
more = true
476
473
}
477
474
for j , entry := range entries [i : i + n ] {
478
- entryRevisions [j ].Id = entry .Id
479
- entryRevisions [j ].RevisionNumber = entry .RevisionNumber
480
- entryRevisions [j ].CreatedAt = entry .CreatedAt
475
+ entryRevisions [j ].Id = entry .GetId ()
476
+ entryRevisions [j ].RevisionNumber = entry .GetRevisionNumber ()
477
+ entryRevisions [j ].CreatedAt = entry .GetCreatedAt ()
481
478
}
482
479
483
480
if err := stream .Send (& entryv1.SyncAuthorizedEntriesResponse {
@@ -530,7 +527,7 @@ func SyncAuthorizedEntries(stream entryv1.Entry_SyncAuthorizedEntriesServer, ent
530
527
entriesToSearch := entries
531
528
for _ , id := range req .Ids {
532
529
i , found := sort .Find (len (entriesToSearch ), func (i int ) int {
533
- return strings .Compare (id , entriesToSearch [i ].Id )
530
+ return strings .Compare (id , entriesToSearch [i ].GetId () )
534
531
})
535
532
if found {
536
533
if len (resp .Entries ) == entryPageSize {
@@ -543,7 +540,7 @@ func SyncAuthorizedEntries(stream entryv1.Entry_SyncAuthorizedEntriesServer, ent
543
540
}
544
541
resp .Entries = resp .Entries [:0 ]
545
542
}
546
- resp .Entries = append (resp .Entries , entriesToSearch [i ])
543
+ resp .Entries = append (resp .Entries , entriesToSearch [i ]. Clone ( initialOutputMask ) )
547
544
}
548
545
entriesToSearch = entriesToSearch [i :]
549
546
if len (entriesToSearch ) == 0 {
@@ -560,7 +557,7 @@ func SyncAuthorizedEntries(stream entryv1.Entry_SyncAuthorizedEntriesServer, ent
560
557
}
561
558
562
559
// fetchEntries fetches authorized entries using caller ID from context
563
- func (s * Service ) fetchEntries (ctx context.Context , log logrus.FieldLogger ) ([]* types. Entry , error ) {
560
+ func (s * Service ) fetchEntries (ctx context.Context , log logrus.FieldLogger ) ([]api. ReadOnlyEntry , error ) {
564
561
callerID , ok := rpccontext .CallerID (ctx )
565
562
if ! ok {
566
563
return nil , api .MakeErr (log , codes .Internal , "caller ID missing from request context" , nil )
@@ -844,8 +841,8 @@ func fieldsFromCountEntryFilter(ctx context.Context, td spiffeid.TrustDomain, fi
844
841
return fields
845
842
}
846
843
847
- func sortEntriesByID (entries []* types. Entry ) {
844
+ func sortEntriesByID (entries []api. ReadOnlyEntry ) {
848
845
sort .Slice (entries , func (a , b int ) bool {
849
- return entries [a ].Id < entries [b ].Id
846
+ return entries [a ].GetId () < entries [b ].GetId ()
850
847
})
851
848
}
0 commit comments