Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default scope when updating an existing provider with occ #433

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/Command/UpsertProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ protected function execute(InputInterface $input, OutputInterface $output) {

$provider = $this->providerService->getProviderByIdentifier($identifier);
if ($provider !== null) {
// existing provider, keep values that are not set
$clientid = $clientid ?? $provider->getClientId();
$clientsecret = $clientsecret ?? $provider->getClientSecret();
$discoveryuri = $discoveryuri ?? $provider->getDiscoveryEndpoint();
$scope = $scope ?? $provider->getScope();
} else {
// new provider default scope value
$scope = $scope ?? 'openid email profile';
}
$scope = $scope ?? 'openid email profile';
try {
$provider = $this->providerMapper->createOrUpdateProvider($identifier, $clientid, $clientsecret, $discoveryuri, $scope);
// invalidate JWKS cache (even if it was just created)
Expand Down
4 changes: 2 additions & 2 deletions lib/Db/ProviderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getProviders() {
}

/**
* Create or update provider settinngs
* Create or update provider settings
*
* @param string identifier
* @param string|null $clientid
Expand All @@ -108,7 +108,7 @@ public function createOrUpdateProvider(string $identifier, string $clientid = nu
if ($provider === null) {
$provider = new Provider();
if (($clientid === null) || ($clientsecret === null) || ($discoveryuri === null)) {
throw new DoesNotExistException("Provider must be created. All provider parameters required.");
throw new DoesNotExistException('Provider must be created. All provider parameters required.');
}
$provider->setIdentifier($identifier);
$provider->setClientId($clientid);
Expand Down