diff --git a/lib/Controller/ConfigController.php b/lib/Controller/ConfigController.php
index 02b9a6ab4..67ffce4d8 100755
--- a/lib/Controller/ConfigController.php
+++ b/lib/Controller/ConfigController.php
@@ -383,6 +383,7 @@ private function setIntegrationConfig(array $values): array {
}
}
$this->clearUserInfo($userUID);
+ $this->clearUserInfoForOIDCBasedAuth($userUID);
});
}
diff --git a/lib/Controller/OpenProjectAPIController.php b/lib/Controller/OpenProjectAPIController.php
index 99f777873..8b2ceb1c2 100644
--- a/lib/Controller/OpenProjectAPIController.php
+++ b/lib/Controller/OpenProjectAPIController.php
@@ -126,11 +126,16 @@ public function getOpenProjectAvatar(string $userId = '', string $userName = '')
* @return DataResponse
*/
public function getNotifications(): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
$result = $this->openprojectAPIService->getNotifications($this->userId);
if (!isset($result['error'])) {
$response = new DataResponse($result);
@@ -237,11 +242,16 @@ public function linkWorkPackageToFile(array $values): DataResponse {
* @return DataResponse
*/
public function markNotificationAsRead(int $workpackageId) {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
try {
$result = $this->openprojectAPIService->markAllNotificationsOfWorkPackageAsRead(
$workpackageId,
@@ -334,11 +344,16 @@ public function deleteFileLink(int $id): DataResponse {
* @return DataResponse
*/
public function getOpenProjectWorkPackageStatus(string $id): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
$result = $this->openprojectAPIService->getOpenProjectWorkPackageStatus(
$this->userId, $id
@@ -361,11 +376,16 @@ public function getOpenProjectWorkPackageStatus(string $id): DataResponse {
* @return DataResponse
*/
public function getOpenProjectWorkPackageType(string $id): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
$result = $this->openprojectAPIService->getOpenProjectWorkPackageType(
$this->userId, $id
@@ -384,11 +404,16 @@ public function getOpenProjectWorkPackageType(string $id): DataResponse {
* @return DataResponse
*/
public function getAvailableOpenProjectProjects(?string $searchQuery = null): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
try {
$result = $this->openprojectAPIService->getAvailableOpenProjectProjects($this->userId, $searchQuery);
} catch (OpenprojectErrorException $e) {
@@ -436,11 +461,16 @@ public function getAvailableOpenProjectProjects(?string $searchQuery = null): Da
* @return DataResponse
*/
public function getOpenProjectWorkPackageForm(string $projectId, array $body): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
try {
$result = $this->openprojectAPIService->getOpenProjectWorkPackageForm($this->userId, $projectId, $body);
} catch (OpenprojectErrorException $e) {
@@ -458,11 +488,16 @@ public function getOpenProjectWorkPackageForm(string $projectId, array $body): D
* @return DataResponse
*/
public function getAvailableAssigneesOfAProject(string $projectId): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
try {
$result = $this->openprojectAPIService->getAvailableAssigneesOfAProject($this->userId, $projectId);
} catch (OpenprojectErrorException $e) {
@@ -507,11 +542,16 @@ public function getAvailableAssigneesOfAProject(string $projectId): DataResponse
* @return DataResponse
*/
public function createWorkPackage(array $body): DataResponse {
- if ($this->accessToken === '') {
- return new DataResponse('', Http::STATUS_UNAUTHORIZED);
- } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
- return new DataResponse('', Http::STATUS_BAD_REQUEST);
- }
+ $user_value = $this->config->getUserValue($this->userId, Application::APP_ID, 'token_active_for_user');
+ if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oauth2' && $this->accessToken === '') {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } else if ($this->config->getAppValue(Application::APP_ID, 'authentication_method', '') === 'oidc' &&
+ $user_value === '0'
+ ) {
+ return new DataResponse('', Http::STATUS_UNAUTHORIZED);
+ } elseif (!OpenProjectAPIService::validateURL($this->openprojectUrl)) {
+ return new DataResponse('', Http::STATUS_BAD_REQUEST);
+ }
// we don't want to check if all the data in the body is set or not because
// that calculation will be done by the openproject api itself
// we don't want to duplicate the logic
diff --git a/lib/Dashboard/OpenProjectWidget.php b/lib/Dashboard/OpenProjectWidget.php
index 04bd475d7..7f9ee9176 100644
--- a/lib/Dashboard/OpenProjectWidget.php
+++ b/lib/Dashboard/OpenProjectWidget.php
@@ -123,6 +123,10 @@ public function load(): void {
$this->config->deleteUserValue(
$this->user->getUID(), Application::APP_ID, 'oauth_connection_result'
);
+ $adminConfigStatusOIDC = OpenProjectAPIService::isAdminConfigOkForOIDCAuth($this->config);
+ $this->initialStateService->provideInitialState('admin-config-status-oidc', $adminConfigStatusOIDC);
+ $authenticationMethodActive = $this->config->getAppValue(Application::APP_ID, 'authentication_method', '');
+ $this->initialStateService->provideInitialState('auth_method', $authenticationMethodActive);
$this->initialStateService->provideInitialState(
'oauth-connection-result', $oauthConnectionResult
);
diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue
index b6fe9f791..9a12ea9e3 100644
--- a/src/components/AdminSettings.vue
+++ b/src/components/AdminSettings.vue
@@ -831,7 +831,6 @@ export default {
},
methods: {
init() {
- console.log(this.state)
if (this.state) {
if (this.state.all_terms_of_services_signed === false) {
this.isAllTermsOfServiceSignedForUserOpenProject = false
diff --git a/src/components/OAuthConnectButton.vue b/src/components/OAuthConnectButton.vue
index 0cd009de9..50f1cd714 100644
--- a/src/components/OAuthConnectButton.vue
+++ b/src/components/OAuthConnectButton.vue
@@ -76,7 +76,6 @@ export default {
},
async onOAuthClick() {
if (this.isAuthMethod === 'oidc') {
- console.log('Handle connect button for the oidc authentication flow!')
const url = generateUrl('/apps/integration_openproject/config')
const req = {
values: {
@@ -85,7 +84,6 @@ export default {
}
const response = await axios.put(url, req)
if (response.status === 200) {
- console.log('Yes its 200')
window.location.reload()
}
diff --git a/src/components/PersonalSettings.vue b/src/components/PersonalSettings.vue
index 4e464475c..7a9b209ee 100644
--- a/src/components/PersonalSettings.vue
+++ b/src/components/PersonalSettings.vue
@@ -94,9 +94,6 @@ export default {
})
},
},
- created() {
- console.log(this.state)
- },
mounted() {
checkOauthConnectionResult(this.oauthConnectionResult, this.oauthConnectionErrorMessage)
diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue
index 0f71b5b3f..5e124eae3 100644
--- a/src/views/Dashboard.vue
+++ b/src/views/Dashboard.vue
@@ -9,8 +9,9 @@