OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Linked up storage authorization in the frontend
Andreas Pfohl79ec43506208
diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex f35b3226491..b75a89c93fa 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -76,6 +76,7 @@"ng-dynamic-component": "^6.0.0","ng2-charts": "^2.3.1","ng2-dragula": "^2.1.1",+ "ngx-cookie-service": "^14.0.0","observable-array": "0.0.4","pako": "^2.0.3","reactivestates": "2.0.1",@@ -88,6 +89,7 @@"ts-action-operators": "^9.1.2","typedjson": "^1.5.1","urijs": "^1.19.11",+ "uuid": "^8.3.2","zone.js": "~0.11.4"},"devDependencies": {@@ -115,6 +117,7 @@"@types/resize-observer-browser": "^0.1.4","@types/swagger-ui": "^3.47.0","@types/urijs": "^1.19.6",+ "@types/uuid": "^8.3.4","@types/webpack-env": "^1.16.0","@typescript-eslint/eslint-plugin": "4.23.0","@typescript-eslint/parser": "4.23.0",@@ -763,14 +766,6 @@"node": ">=10"}},- "node_modules/@angular/cli/node_modules/uuid": {- "version": "8.3.2",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",- "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",- "bin": {- "uuid": "dist/bin/uuid"- }- },"node_modules/@angular/common": {"version": "12.2.6","resolved": "https://registry.npmjs.org/@angular/common/-/common-12.2.6.tgz",@@ -5552,6 +5547,12 @@"integrity": "sha512-kdnK+JtEiUgnpB7r99SAZjjz9nhZ/7MWo/hxTSNfvslAa4r8jpDXDEJ2cQrjemes4eX2Y5Om3udmcc8QalPzOA==","dev": true},+ "node_modules/@types/uuid": {+ "version": "8.3.4",+ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",+ "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==",+ "dev": true+ },"node_modules/@types/webpack-env": {"version": "1.16.0","resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.16.0.tgz",@@ -14726,6 +14727,16 @@"integrity": "sha512-bpcvu/MKHHeYX+qeEN8GE7DIravODWdACVA1ctevD8CN24RhPZIKMn9ntfAsrvLfSX3cR5RrBKAbYm9bGs0A+Q==","dev": true},+ "node_modules/jayson/node_modules/uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "dev": true,+ "bin": {+ "uuid": "bin/uuid"+ }+ },"node_modules/jest-worker": {"version": "27.1.0","resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.1.0.tgz",@@ -16463,6 +16474,18 @@"resolved": "https://registry.npmjs.org/@types/dragula/-/dragula-2.1.35.tgz","integrity": "sha512-kh0O22j8QVh7xU0P6Penwext6xVMNldVEzvtOAHU1/AzdluYstc9pe2nUL3fS6IZRyzSoSGvdR/u8zP2iIZmnA=="},+ "node_modules/ngx-cookie-service": {+ "version": "14.0.0",+ "resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-14.0.0.tgz",+ "integrity": "sha512-Yur9aIrtcqkI40UgvIN8VLoOzxhI3o/yWc16Q/buvprapTQzYdplNZ5chjb50SYaREiJdXfj7Wc49YG+9ABX1A==",+ "dependencies": {+ "tslib": "^2.0.0"+ },+ "peerDependencies": {+ "@angular/common": "^14.0.0",+ "@angular/core": "^14.0.0"+ }+ },"node_modules/nice-napi": {"version": "1.0.2","resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",@@ -20837,6 +20860,15 @@"node": ">=0.6"}},+ "node_modules/request/node_modules/uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "bin": {+ "uuid": "bin/uuid"+ }+ },"node_modules/require-directory": {"version": "2.1.1","resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",@@ -22177,6 +22209,16 @@"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==","dev": true},+ "node_modules/sockjs/node_modules/uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "dev": true,+ "bin": {+ "uuid": "bin/uuid"+ }+ },"node_modules/socks": {"version": "2.6.1","resolved": "https://registry.npmjs.org/socks/-/socks-2.6.1.tgz",@@ -24270,12 +24312,11 @@}},"node_modules/uuid": {- "version": "3.4.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",- "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",- "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "version": "8.3.2",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==","bin": {- "uuid": "bin/uuid"+ "uuid": "dist/bin/uuid"}},"node_modules/v8-compile-cache": {@@ -25214,6 +25255,16 @@"node": ">=6"}},+ "node_modules/webpack-log/node_modules/uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "dev": true,+ "bin": {+ "uuid": "bin/uuid"+ }+ },"node_modules/webpack-merge": {"version": "5.8.0","resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz",@@ -26021,11 +26072,6 @@"requires": {"lru-cache": "^6.0.0"}- },- "uuid": {- "version": "8.3.2",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",- "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="}}},@@ -29652,6 +29698,12 @@"integrity": "sha512-kdnK+JtEiUgnpB7r99SAZjjz9nhZ/7MWo/hxTSNfvslAa4r8jpDXDEJ2cQrjemes4eX2Y5Om3udmcc8QalPzOA==","dev": true},+ "@types/uuid": {+ "version": "8.3.4",+ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",+ "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==",+ "dev": true+ },"@types/webpack-env": {"version": "1.16.0","resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.16.0.tgz",@@ -36687,6 +36739,12 @@"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.170.tgz","integrity": "sha512-bpcvu/MKHHeYX+qeEN8GE7DIravODWdACVA1ctevD8CN24RhPZIKMn9ntfAsrvLfSX3cR5RrBKAbYm9bGs0A+Q==","dev": true+ },+ "uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "dev": true}}},@@ -38065,6 +38123,14 @@}}},+ "ngx-cookie-service": {+ "version": "14.0.0",+ "resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-14.0.0.tgz",+ "integrity": "sha512-Yur9aIrtcqkI40UgvIN8VLoOzxhI3o/yWc16Q/buvprapTQzYdplNZ5chjb50SYaREiJdXfj7Wc49YG+9ABX1A==",+ "requires": {+ "tslib": "^2.0.0"+ }+ },"nice-napi": {"version": "1.0.2","resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",@@ -41281,6 +41347,11 @@"version": "6.5.2","resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz","integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="+ },+ "uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="}}},@@ -42292,6 +42363,14 @@"faye-websocket": "^0.11.3","uuid": "^3.4.0","websocket-driver": "^0.7.4"+ },+ "dependencies": {+ "uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "dev": true+ }}},"sockjs-client": {@@ -43972,9 +44051,9 @@"dev": true},"uuid": {- "version": "3.4.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",- "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="+ "version": "8.3.2",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="},"v8-compile-cache": {"version": "2.2.0",@@ -44733,6 +44812,12 @@"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz","integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==","dev": true+ },+ "uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "dev": true}}},diff --git a/frontend/package.json b/frontend/package.jsonindex a553f8ea223..c866b599994 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -29,6 +29,7 @@"@types/resize-observer-browser": "^0.1.4","@types/swagger-ui": "^3.47.0","@types/urijs": "^1.19.6",+ "@types/uuid": "^8.3.4","@types/webpack-env": "^1.16.0","@typescript-eslint/eslint-plugin": "4.23.0","@typescript-eslint/parser": "4.23.0",@@ -128,6 +129,7 @@"ng-dynamic-component": "^6.0.0","ng2-charts": "^2.3.1","ng2-dragula": "^2.1.1",+ "ngx-cookie-service": "^14.0.0","observable-array": "0.0.4","pako": "^2.0.3","reactivestates": "2.0.1",@@ -140,6 +142,7 @@"ts-action-operators": "^9.1.2","typedjson": "^1.5.1","urijs": "^1.19.11",+ "uuid": "^8.3.2","zone.js": "~0.11.4"},"scripts": {diff --git a/frontend/src/app/core/state/storages/storage.model.ts b/frontend/src/app/core/state/storages/storage.model.tsindex f9dd815d6a6..6d48c799963 100644--- a/frontend/src/app/core/state/storages/storage.model.ts+++ b/frontend/src/app/core/state/storages/storage.model.ts@@ -34,6 +34,7 @@ export interface IStorageHalResourceLinks extends IHalResourceLinks {type:IHalResourceLink;origin:IHalResourceLink;authorizationState:IHalResourceLink;+ authorize?:IHalResourceLink;}export interface IStorage {diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.tsindex 4e30db4b8f1..1fadf723a78 100644--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts@@ -44,6 +44,8 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.servimport { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { I18nService } from 'core-app/core/i18n/i18n.service';import isNewResource from 'core-app/features/hal/helpers/is-new-resource';+import { CookieService } from 'ngx-cookie-service';+import { v4 as uuidv4 } from 'uuid';@Component({selector: 'op-file-link-list',@@ -94,10 +96,13 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit}};+ private informationActionUrl = '#';+constructor(private readonly i18n:I18nService,private readonly fileLinkResourceService:FileLinksResourceService,private readonly currentUserService:CurrentUserService,+ private readonly cookieService:CookieService,) {super();}@@ -130,7 +135,13 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit}public openStorageLocation():void {- window.open(this.storage._links.origin.href);+ const nonce = uuidv4();++ this.cookieService.set(`oauth_state_${nonce}`, window.location.href, {+ path: '/',+ });++ window.location.href = `${this.informationActionUrl}&state=${nonce}`;}public isDisabled(fileLink:IFileLink):boolean {@@ -173,6 +184,7 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitthis.informationBoxContent = this.text.infoBox.authorizationFailureContent;this.informationBoxButton = this.text.infoBox.loginButton;this.informationBoxIcon = 'import';+ this.informationActionUrl = this.storage._links.authorize?.href as string;this.showInformationBox$.next(true);this.showFileLinks$.next(fileLinkCount > 0);}@@ -182,6 +194,7 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitthis.informationBoxContent = this.text.infoBox.connectionErrorContent;this.informationBoxButton = this.text.infoBox.loginButton;this.informationBoxIcon = 'remove-link';+ this.informationActionUrl = this.storage._links.origin.href;this.showInformationBox$.next(true);this.showFileLinks$.next(false);}diff --git a/frontend/src/app/shared/components/file-links/openproject-file-links.module.ts b/frontend/src/app/shared/components/file-links/openproject-file-links.module.tsindex 84464128a98..9d3339ec9fc 100644--- a/frontend/src/app/shared/components/file-links/openproject-file-links.module.ts+++ b/frontend/src/app/shared/components/file-links/openproject-file-links.module.ts@@ -37,6 +37,7 @@ import {import {StorageInformationComponent,} from 'core-app/shared/components/file-links/storage-information/storage-information.component';+import { CookieService } from 'ngx-cookie-service';@NgModule({imports: [@@ -51,6 +52,9 @@ import {exports: [FileLinkListComponent,],+ providers: [+ CookieService,+ ],})export class OpenprojectFileLinksModule {}diff --git a/frontend/src/app/shared/components/file-links/storage-information/storage-information.html b/frontend/src/app/shared/components/file-links/storage-information/storage-information.htmlindex e493ee164ca..9d3f9347903 100644--- a/frontend/src/app/shared/components/file-links/storage-information/storage-information.html+++ b/frontend/src/app/shared/components/file-links/storage-information/storage-information.html@@ -18,10 +18,19 @@<divclass="button-box">- <button class="button op-files-tab--storage-info-box-button">- <op-icon icon-classes="button--icon spot-icon spot-icon_external-link" class="op-icon--wrapper">- <i class="button--icon spot-icon spot-icon_external-link"></i>+ <button+ class="button op-files-tab--storage-info-box-button"+ (click)="buttonClickEventEmitter.emit()"+ >+ <op-icon+ icon-classes="button--icon spot-icon spot-icon_external-link"+ class="op-icon--wrapper">+ <i+ class="button--icon spot-icon spot-icon_external-link"+ ></i></op-icon>- <span class="button--text">Open Nextcloud</span>+ <span+ class="button--text"+ >{{buttonText}}</span></button></div>