Skip to content

Commit fb35c92

Browse files
committed
Add last updated
1 parent d703286 commit fb35c92

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/Federation/EntityCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function __construct(
2020
protected readonly EntityCollectionPaginator $entityCollectionPaginator,
2121
protected array $entities,
2222
protected ?string $nextPageToken = null,
23+
protected ?int $lastUpdated = null,
2324
) {
2425
}
2526

src/Federation/EntityCollection/EntityCollectionFetcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
* @param non-empty-string $endpointUri
2828
* @param array{
2929
* entity_type?: string[],
30-
* trust_mark_type?: string,
30+
* trust_mark_type?: string[],
3131
* query?: string,
3232
* trust_anchor?: string,
3333
* entity_claims?: string[],

src/Federation/Factories/EntityCollectionFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ public function __construct(
2323
* @param array<string, array<string, mixed>> $entities Keyed by entity ID,
2424
* value is JWT payload
2525
*/
26-
public function build(array $entities): EntityCollection
26+
public function build(array $entities, ?int $lastUpdated): EntityCollection
2727
{
2828
return new EntityCollection(
2929
$this->entityCollectionFilter,
3030
$this->entityCollectionSorter,
3131
$this->entityCollectionPaginator,
3232
$entities,
33+
$lastUpdated,
3334
);
3435
}
3536
}

src/Federation/FederationDiscovery.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public function discover(
4646
'Returning discovered entities from entity collection store.',
4747
['trustAnchorId' => $trustAnchorId],
4848
);
49-
return $this->entityCollectionFactory->build($cachedEntities);
49+
return $this->entityCollectionFactory->build(
50+
$cachedEntities,
51+
$this->entityCollectionStore->getLastUpdated($trustAnchorId),
52+
);
5053
}
5154
}
5255

@@ -56,6 +59,7 @@ public function discover(
5659
);
5760

5861
$discoveredEntities = [];
62+
$lastUpdated = null;
5963
try {
6064
// Step 1: Fetch TA config
6165
$taConfig = $this->entityStatementFetcher->fromCacheOrWellKnownEndpoint($trustAnchorId);
@@ -71,7 +75,8 @@ public function discover(
7175
ksort($discoveredEntities);
7276

7377
$this->entityCollectionStore->store($trustAnchorId, $discoveredEntities, $ttl);
74-
$this->entityCollectionStore->storeLastUpdated($trustAnchorId, time(), $ttl);
78+
$lastUpdated = time();
79+
$this->entityCollectionStore->storeLastUpdated($trustAnchorId, $lastUpdated, $ttl);
7580

7681
$this->logger?->info('Federation discovery completed.', [
7782
'trustAnchorId' => $trustAnchorId,
@@ -84,7 +89,7 @@ public function discover(
8489
]);
8590
}
8691

87-
return $this->entityCollectionFactory->build($discoveredEntities);
92+
return $this->entityCollectionFactory->build($discoveredEntities, $lastUpdated);
8893
}
8994

9095

0 commit comments

Comments
 (0)