Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fix: Default OIDC provider name not set while updating to Nextcloud Hub setup [#1126](https://github.com/nextcloud/integration_openproject/pull/1126)
- Fix: User shown connected in webUI after converting existing OAuth to SSO via setup endpoint [#1132](https://github.com/nextcloud/integration_openproject/pull/1132)

### Changed

Expand Down
22 changes: 8 additions & 14 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,9 @@ private function setIntegrationConfig(array $values): array {
}
// since we can now switch between both authorization method we need to know what we are resetting (either "oauth2" or "oidc" method)
// determines if we are switching from "oauth2" to "oidc" auth method
$runningOauth2Reset = (
key_exists('openproject_client_id', $values) &&
!$values['openproject_client_id'] &&
key_exists('openproject_client_secret', $values) &&
!$values['openproject_client_secret'] &&
$oldOpenProjectOauthUrl &&
$oldClientId &&
$oldClientSecret
$switchingOauthToOIDC = (
$oldAuthMethod === Application::AUTH_METHOD_OAUTH && key_exists('authorization_method', $values) &&
$values['authorization_method'] === Application::AUTH_METHOD_OIDC
);

// determines if we are switching from "oidc" to "oauth2" auth method
Expand Down Expand Up @@ -309,13 +304,14 @@ private function setIntegrationConfig(array $values): array {
}

$this->config->deleteAppValue(Application::APP_ID, 'oPOAuthTokenRevokeStatus');
$resetOpenProjectClient = ((key_exists('openproject_client_id', $values) && $values['openproject_client_id'] !== $oldClientId) ||
(key_exists('openproject_client_secret', $values) && $values['openproject_client_secret'] !== $oldClientSecret));
if (
// when the OP client information has changed
(!$runningFullResetWithOIDCAuth && ((key_exists('openproject_client_id', $values) && $values['openproject_client_id'] !== $oldClientId) ||
(key_exists('openproject_client_secret', $values) && $values['openproject_client_secret'] !== $oldClientSecret))) ||
(!$runningFullResetWithOIDCAuth && $resetOpenProjectClient) ||
// when the OP client information is reset
$runningFullResetWithOAuth2Auth ||
$runningOauth2Reset
$switchingOauthToOIDC
) {
$this->userManager->callForAllUsers(function (IUser $user) use (
$oldOpenProjectOauthUrl, $oldClientId, $oldClientSecret
Expand Down Expand Up @@ -377,9 +373,7 @@ private function setIntegrationConfig(array $values): array {
$this->config->setAppValue(Application::APP_ID, 'fresh_project_folder_setup', "0");
}

// when switching from "oauth2" to "oidc" authorization method
if (key_exists('authorization_method', $values) &&
$values['authorization_method'] === Application::AUTH_METHOD_OIDC && $runningOauth2Reset) {
if ($switchingOauthToOIDC) {
$this->resetOauth2Configs();
}

Expand Down
Loading