Skip to content

Commit 054a4ba

Browse files
committed
Log error if client id and client secret are the same
1 parent ee2ccbb commit 054a4ba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Classes/OAuthClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ public function startAuthorization(string $clientId, string $clientSecret, UriIn
266266
$oAuthProvider = $this->createOAuthProvider($clientId, $clientSecret);
267267
$authorizationUri = new Uri($oAuthProvider->getAuthorizationUrl(['scope' => $scope]));
268268

269+
if ($clientId === $clientSecret) {
270+
$this->logger->error(sprintf('OAuth (%s): Client ID and Client secret are the same! Please check your configuration.', $this->getServiceType()));
271+
}
272+
269273
try {
270274
$this->stateCache->set(
271275
$oAuthProvider->getState(),
@@ -311,6 +315,7 @@ public function finishAuthorization(string $stateIdentifier, string $code, strin
311315
throw new OAuthClientException(sprintf('OAuth2 (%s): Finishing authorization failed because authorization %s could not be retrieved from the database.', $this->getServiceType(), $authorizationId), 1568710771);
312316
}
313317

318+
$this->logger->debug(sprintf('OAuth (%s): Retrieving an OAuth access token for authorization "%s" in exchange for the code %s', $this->getServiceType(), $authorizationId, str_repeat('*', strlen($code) - 3) . substr($code, -3, 3)));
314319
$accessToken = $oAuthProvider->getAccessToken(Authorization::GRANT_AUTHORIZATION_CODE, ['code' => $code]);
315320
$this->logger->info(sprintf('OAuth (%s): Persisting OAuth token for authorization "%s" with expiry time %s.', $this->getServiceType(), $authorizationId, $accessToken->getExpires()));
316321

0 commit comments

Comments
 (0)