Skip to content

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

Extend turbo request headers so that on a failing authentication it will not render the basic auch login modal

Wieland Lindenthal3c137204e652
diff --git a/frontend/src/app/core/turbo/turbo-requests.service.ts b/frontend/src/app/core/turbo/turbo-requests.service.ts
index 0c8ab601d49..97a6d98e757 100644
--- a/frontend/src/app/core/turbo/turbo-requests.service.ts
+++ b/frontend/src/app/core/turbo/turbo-requests.service.ts
@@ -59,6 +59,7 @@ export class TurboRequestsService {
body: formData,
headers: {
'X-CSRF-Token': (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content,
+ 'X-Authentication-Scheme': 'Session',
},
},
true,
@@ -68,7 +69,10 @@ export class TurboRequestsService {
public requestStream(url:string):Promise<{ html:string, headers:Headers }> {
return this.request(url, {
method: 'GET',
- headers: { Accept: 'text/vnd.turbo-stream.html' },
+ headers: {
+ Accept: 'text/vnd.turbo-stream.html',
+ 'X-Authentication-Scheme': 'Session',
+ },
credentials: 'same-origin',
});
}
diff --git a/frontend/src/stimulus/controllers/async-dialog.controller.ts b/frontend/src/stimulus/controllers/async-dialog.controller.ts
index 2d0892701fe..9b4197abf7b 100644
--- a/frontend/src/stimulus/controllers/async-dialog.controller.ts
+++ b/frontend/src/stimulus/controllers/async-dialog.controller.ts
@@ -47,6 +47,7 @@ export default class AsyncDialogController extends ApplicationController {
method: this.method,
headers: {
Accept: 'text/vnd.turbo-stream.html',
+ 'X-Authentication-Scheme': 'Session',
},
}).then((r) => r.text())
.then((html) => {
diff --git a/frontend/src/stimulus/controllers/dynamic/meetings/form.controller.ts b/frontend/src/stimulus/controllers/dynamic/meetings/form.controller.ts
index 37dab0e9f47..28c8033602e 100644
--- a/frontend/src/stimulus/controllers/dynamic/meetings/form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/meetings/form.controller.ts
@@ -57,7 +57,10 @@ export default class OpMeetingsFormController extends ApplicationController {
.request(
`${this.pathHelper.staticBase}/meetings/fetch_timezone?${urlSearchParams.toString()}`,
{
- headers: { Accept: 'text/vnd.turbo-stream.html' },
+ headers: {
+ Accept: 'text/vnd.turbo-stream.html',
+ 'X-Authentication-Scheme': 'Session',
+ },
},
);
}
diff --git a/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts b/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts
index 64c6e0044bf..d909e4b68aa 100644
--- a/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts
@@ -25,7 +25,10 @@ export default class OpRecurringMeetingsFormController extends ApplicationContro
.request(
`${this.pathHelper.staticBase}/recurring_meetings/humanize_schedule?${urlSearchParams.toString()}`,
{
- headers: { Accept: 'text/vnd.turbo-stream.html' },
+ headers: {
+ Accept: 'text/vnd.turbo-stream.html',
+ 'X-Authentication-Scheme': 'Session',
+ },
},
);
}
diff --git a/frontend/src/turbo/turbo-event-listeners.ts b/frontend/src/turbo/turbo-event-listeners.ts
index 18fc192fd33..6fcaf91c669 100644
--- a/frontend/src/turbo/turbo-event-listeners.ts
+++ b/frontend/src/turbo/turbo-event-listeners.ts
@@ -31,6 +31,7 @@ export function addTurboEventListeners() {
const headers = event.detail.fetchOptions.headers as Record<string, string>;
headers['Turbo-Referrer'] = window.location.href;
headers['X-Turbo-Nonce'] = document.getElementsByName('csp-nonce')[0]?.getAttribute('content') || '';
+ headers['X-Authentication-Scheme'] = 'Session';
});
// Turbo adds nonces to all scripts, even though we want to explicitly pass nonces