Skip to content

Commit 2b32831

Browse files
committed
WIP
1 parent fb35c92 commit 2b32831

12 files changed

Lines changed: 341 additions & 692 deletions

docs/3-federation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OpenID Federation Tools (draft 47)
1+
# OpenID Federation Tools
22

33
To use it, create an instance of the class `\SimpleSAML\OpenID\Federation`.
44

docs/5-federation-discovery.md

Lines changed: 152 additions & 318 deletions
Large diffs are not rendered by default.

src/Federation.php

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
use SimpleSAML\OpenID\Factories\HttpClientDecoratorFactory;
2121
use SimpleSAML\OpenID\Factories\JwsSerializerManagerDecoratorFactory;
2222
use SimpleSAML\OpenID\Federation\EntityCollection\CacheEntityCollectionStore;
23-
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionFetcher;
2423
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionFilter;
2524
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionPaginator;
26-
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionResponseFactory;
2725
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionSorter;
2826
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionStoreInterface;
2927
use SimpleSAML\OpenID\Federation\EntityCollection\InMemoryEntityCollectionStore;
@@ -77,16 +75,12 @@ class Federation
7775

7876
protected ?FederationDiscovery $federationDiscovery = null;
7977

80-
protected ?EntityCollectionFetcher $entityCollectionFetcher = null;
81-
8278
protected ?EntityCollectionFilter $entityCollectionFilter = null;
8379

8480
protected ?EntityCollectionSorter $entityCollectionSorter = null;
8581

8682
protected ?EntityCollectionPaginator $entityCollectionPaginator = null;
8783

88-
protected ?EntityCollectionResponseFactory $entityCollectionBuilder = null;
89-
9084
protected ?EntityStatementFetcher $entityStatementFetcher = null;
9185

9286
protected ?MetadataPolicyResolver $metadataPolicyResolver = null;
@@ -399,6 +393,8 @@ public function federationDiscovery(): FederationDiscovery
399393
$this->entityCollectionStore(),
400394
$this->maxCacheDurationDecorator(),
401395
$this->entityCollectionFactory(),
396+
$this->artifactFetcher(),
397+
$this->helpers(),
402398
$this->logger,
403399
$this->maxDiscoveryDepth,
404400
);
@@ -408,16 +404,6 @@ public function federationDiscovery(): FederationDiscovery
408404
}
409405

410406

411-
public function entityCollectionFetcher(): EntityCollectionFetcher
412-
{
413-
return $this->entityCollectionFetcher ??= new EntityCollectionFetcher(
414-
$this->artifactFetcher(),
415-
$this->helpers(),
416-
$this->logger,
417-
);
418-
}
419-
420-
421407
public function entityCollectionFilter(): EntityCollectionFilter
422408
{
423409
return $this->entityCollectionFilter ??= new EntityCollectionFilter($this->helpers());
@@ -438,18 +424,6 @@ public function entityCollectionPaginator(): EntityCollectionPaginator
438424
}
439425

440426

441-
public function entityCollectionResponseFactory(): EntityCollectionResponseFactory
442-
{
443-
return $this->entityCollectionBuilder ??= new EntityCollectionResponseFactory(
444-
$this->federationDiscovery(),
445-
$this->entityCollectionFilter(),
446-
$this->entityCollectionSorter(),
447-
$this->entityCollectionPaginator(),
448-
$this->entityCollectionStore(),
449-
);
450-
}
451-
452-
453427
public function helpers(): Helpers
454428
{
455429
return $this->helpers ??= new Helpers();

src/Federation/EntityCollection.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SimpleSAML\OpenID\Federation;
66

7+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
78
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionFilter;
89
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionPaginator;
910
use SimpleSAML\OpenID\Federation\EntityCollection\EntityCollectionSorter;
@@ -34,6 +35,60 @@ public function getEntities(): array
3435
}
3536

3637

38+
public function getLastUpdated(): ?int
39+
{
40+
return $this->lastUpdated;
41+
}
42+
43+
44+
/**
45+
* @return array{
46+
* entities: array<int, array<string, mixed>>,
47+
* next?: string,
48+
* last_updated?: int
49+
* }
50+
*/
51+
public function toCollectionEndpointResponseArray(): array
52+
{
53+
$entities = [];
54+
foreach ($this->entities as $payload) {
55+
$metadata = $payload[ClaimsEnum::Metadata->value] ?? [];
56+
if (!is_array($metadata)) {
57+
$metadata = [];
58+
}
59+
60+
$entry = [
61+
ClaimsEnum::EntityId->value => $payload[ClaimsEnum::Sub->value] ?? '',
62+
ClaimsEnum::EntityTypes->value => array_keys($metadata),
63+
];
64+
65+
if ($metadata !== []) {
66+
$entry[ClaimsEnum::UiInfos->value] = $metadata;
67+
}
68+
69+
if (isset($payload[ClaimsEnum::TrustMarks->value])) {
70+
$entry[ClaimsEnum::TrustMarks->value] = $payload[ClaimsEnum::TrustMarks->value];
71+
}
72+
73+
$entities[] = $entry;
74+
}
75+
76+
$data = [
77+
ClaimsEnum::Entities->value => $entities,
78+
];
79+
80+
if (!is_null($this->nextPageToken)) {
81+
$data[ClaimsEnum::Next->value] = $this->nextPageToken;
82+
}
83+
84+
if (!is_null($this->lastUpdated)) {
85+
$data[ClaimsEnum::LastUpdated->value] = $this->lastUpdated;
86+
}
87+
88+
return $data;
89+
}
90+
91+
3792
/**
3893
* Apply filters to the collection. Supported criteria keys:
3994
* - entity_type: array of entity types to include

src/Federation/EntityCollection/EntityCollectionEntry.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/Federation/EntityCollection/EntityCollectionFetcher.php

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/Federation/EntityCollection/EntityCollectionResponse.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)