Skip to content

Commit 9cf4b9d

Browse files
committed
ensure trust boundaries are retrieved if x-allowed-locations exists
1 parent 35b4874 commit 9cf4b9d

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/TrustBoundaryTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ private function getTrustBoundary(
3737
return null;
3838
}
3939

40+
if (array_key_exists('x-allowed-locations', $headers)) {
41+
// If the headers are already set, do not set them
42+
return null;
43+
}
44+
4045
// Return cached value if it exists
4146
if ($cached = $this->getCachedValue($this->getCacheKey() . ':trustboundary')) {
4247
return $cached;
4348
}
44-
4549
if (!array_key_exists('authorization', $headers)) {
4650
// If we don't have an authorization token we can't look up the trust boundary
4751
return null;

tests/TrustBoundaryTraitTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ public function testSkipLookupOutsideDefaultUniverseDomain()
144144
$this->assertNull($result1);
145145
}
146146

147+
public function testSkipLookupIfXAllowedLocationsAreAlreadySet()
148+
{
149+
// First call, should fetch and cache
150+
$result1 = $this->impl->getTrustBoundary(
151+
'universe.domain',
152+
fn () => throw new \Exception('Should not be called'),
153+
'default',
154+
['authorization' => ['xyz'], ['x-allowed-locations' => 'abc']]
155+
);
156+
157+
$this->assertNull($result1);
158+
}
159+
147160
public function testLookupIsFailOpen()
148161
{
149162
$mock = new MockHandler([

0 commit comments

Comments
 (0)