Content
View differences
Updated by Ashim Shrestha 11 days ago
### Steps to reproduce
* Setup `integration_openproject` with `OAuth`.
* Connect the Nextcloud admin with an OpenProject admin.
* Convert the existing `OAuth` integration setup to `SSO` by:
```bash
curl -s -XPATCH 'https://nextcloud.local/index.php/apps/integration_openproject/setup' \
-H 'Content-Type: application/json' \
-d '{
"values": {
"sso_provider_type": "nextcloud_hub",
"authorization_method": "oidc",
"targeted_audience_client_id": "openproject"
}
}' \
-u admin:admin
```
* and the Response should be:
```json
{"status": true}
```
* In `Nextcloud`, navigate to `Personal settings` -> `OpenProject`
<br>
### What is the buggy behavior?
* OpenProject Integration status shows `Connected as OpenProject Admin` in the webUI
<br>
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/923175/content">
<br>
Then
* In Nextcloud, navigate to `Administration settings` -> `OpenProject` and `reset` the OpenProject integration setup.
* `Nextcloud OAuth client ID` and `Nextcloud OAuth client secret` are not deleted.
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/923660/content">
### What is the expected behavior?
* OpenProject Integration status should show `Unauthorized to connect to OpenProject` in the webUI
Or, error related to settings not available (for Nextcloud users)
<br>
<img class="image_resized op-uc-image op-uc-image_inline" style="width:931px;" src="/api/v3/attachments/923174/content">
Then
* In Nextcloud, navigate to `Administration settings` -> `OpenProject` and `reset` the OpenProject integration setup.
* `Nextcloud OAuth client ID` and `Nextcloud OAuth client secret` should be deleted.
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/923661/content">
### Cause
In function `setIntegrationConfig`:
the following `if` block is never `true` for converting existing `OAuth` to `SSO`
```php
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))) ||
// when the OP client information is reset
$runningFullResetWithOAuth2Auth ||
$runningOauth2Reset
)
```
so deleting the `token` is not called
```php
$this->clearUserInfo($userUID);
```
the bug is in how the value of variable `$runningOauth2Reset` is computed
### Environment information
integration\_openproject `3.1` and nextcloud `34`
**OpenProject installation type**
* Docker-compose installation
**Browser**
* [x] Chrome
* [ ] Firefox
* [ ] Safari
* [ ] Mobile Safari
* [ ] Other (please specify)
**Operating System**
* [ ] Windows
* [ ] Mac OS X
* [ ] Mobile iOS
* [ ] Mobile Android
* [x] Linux (please specify distro)
* [ ] Chrome OS
* [ ] Other (please specify)
* Setup `integration_openproject` with `OAuth`.
* Connect the Nextcloud admin with an OpenProject admin.
* Convert the existing `OAuth` integration setup to `SSO` by:
```bash
curl -s -XPATCH 'https://nextcloud.local/index.php/apps/integration_openproject/setup' \
-H 'Content-Type: application/json' \
-d '{
"values": {
"sso_provider_type": "nextcloud_hub",
"authorization_method": "oidc",
"targeted_audience_client_id": "openproject"
}
}' \
-u admin:admin
```
* and the Response should be:
```json
{"status": true}
```
* In `Nextcloud`, navigate to `Personal settings` -> `OpenProject`
<br>
### What is the buggy behavior?
* OpenProject Integration status shows `Connected as OpenProject Admin` in the webUI
<br>
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/923175/content">
<br>
Then
* In Nextcloud, navigate to `Administration settings` -> `OpenProject` and `reset` the OpenProject integration setup.
* `Nextcloud OAuth client ID` and `Nextcloud OAuth client secret` are not deleted.
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/923660/content">
### What is the expected behavior?
* OpenProject Integration status should show `Unauthorized to connect to OpenProject` in the webUI
Or, error related to settings not available (for Nextcloud users)
<br>
<img class="image_resized op-uc-image op-uc-image_inline" style="width:931px;" src="/api/v3/attachments/923174/content">
Then
* In Nextcloud, navigate to `Administration settings` -> `OpenProject` and `reset` the OpenProject integration setup.
* `Nextcloud OAuth client ID` and `Nextcloud OAuth client secret` should be deleted.
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/923661/content">
### Cause
In function `setIntegrationConfig`:
the following `if` block is never `true` for converting existing `OAuth` to `SSO`
```php
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))) ||
// when the OP client information is reset
$runningFullResetWithOAuth2Auth ||
$runningOauth2Reset
)
```
so deleting the `token` is not called
```php
$this->clearUserInfo($userUID);
```
the bug is in how the value of variable `$runningOauth2Reset` is computed
### Environment information
integration\_openproject `3.1` and nextcloud `34`
**OpenProject installation type**
* Docker-compose installation
**Browser**
* [x] Chrome
* [ ] Firefox
* [ ] Safari
* [ ] Mobile Safari
* [ ] Other (please specify)
**Operating System**
* [ ] Windows
* [ ] Mac OS X
* [ ] Mobile iOS
* [ ] Mobile Android
* [x] Linux (please specify distro)
* [ ] Chrome OS
* [ ] Other (please specify)