Skip to content

Commit bd0a32c

Browse files
committed
Add option to override well-known URL
1 parent 692ef41 commit bd0a32c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/BYUJWT.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class BYUJWT
3030
{
3131
protected $client;
3232
protected $cache = [];
33+
protected $wellKnownUrl;
3334

3435
public $lastException;
3536

@@ -52,6 +53,11 @@ public function __construct($settings = [])
5253
} else {
5354
$this->client = $settings['client'];
5455
}
56+
57+
$this->wellKnownUrl = 'https://api.byu.edu/.well-known/openid-configuration';
58+
if (!empty($settings['wellKnownUrl'])) {
59+
$this->wellKnownUrl = $settings['wellKnownUrl'];
60+
}
5561
}
5662

5763
/**
@@ -67,8 +73,7 @@ public function getWellKnown()
6773
}
6874

6975
try {
70-
$wellKnownUrl = 'https://api.byu.edu/.well-known/openid-configuration';
71-
$response = $this->client->get($wellKnownUrl);
76+
$response = $this->client->get($this->wellKnownUrl);
7277
} catch (RequestException $e) {
7378
$this->lastException = $e;
7479
return null;

tests/BYUJWTTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ public function testBadWellKnown()
105105
$this->assertEmpty($BYUJWT->getWellKnown());
106106
}
107107

108+
public function testBadWellKnownUrl()
109+
{
110+
$BYUJWT = new BYUJWT(['wellKnownUrl' => 'badprotocol://fakeurl']);
111+
112+
$this->assertEmpty($BYUJWT->getWellKnown());
113+
$this->assertInstanceOf(
114+
'GuzzleHttp\Exception\RequestException',
115+
$BYUJWT->lastException
116+
);
117+
}
118+
108119
public function testMissingJwks()
109120
{
110121
$client = $this->mockClient([static::$openid]);

0 commit comments

Comments
 (0)