OAuth2 client credentials flow with cache

This commit is contained in:
2024-11-10 23:32:27 +01:00
parent 255d0189ab
commit fde083f36f
4 changed files with 112 additions and 46 deletions

View File

@@ -154,16 +154,19 @@ class APIClientFactory {
'timeout' => self::DEFAULT_TIMEOUT
];
if ($this->reader->hasProperty($api, 'wa:hasAuthorizationServer')) {
if ($this->reader->hasProperty($api, 'oauth2:hasAuthorizationServer')) {
// We have an authorization server for this endpoint/API
$authServerCoid = $this->reader->getFirstValueIRI($api, 'wa:hasAuthorizationServer');
$authServerCoid = $this->reader->getFirstValueIRI($api, 'oauth2:hasAuthorizationServer');
$authServerObject = $this->objectRetriever->getObject($authServerCoid);
if (!isset($authServer))
if (!isset($authServerObject))
throw new InvalidObjectConfigurationException("Authorization server object <"
. (string)$authServerCoid . "> not available.");
try {
$authServer = new OAuth2AuthServer($authServerObject);
$authServer = new OAuth2AuthServer($authServerObject, $this->objectRetriever);
} catch (InvalidObjectConfigurationException $e) {
throw new InvalidObjectConfigurationException("Authorization server object <"
. (string)$authServerCoid . "> could not be loaded; error: " . $e->getMessage());
} catch (Exception $e) {
throw new InvalidObjectConfigurationException("Authorization server object <"
. (string)$authServerCoid . "> could not be loaded. Its definition may be invalid.");