From 0e0241f252a25158636c08a4ec4aeb0428783648 Mon Sep 17 00:00:00 2001 From: Thomas Jaeckle Date: Mon, 6 Mar 2023 20:12:58 +0100 Subject: [PATCH 01/42] [#1592] provide "Bearer" authentication for devops resources controlled via UI * added radiobutton groups so that "Authorize" modal clearly shows/states which authentication to use where * reduced to a single "Authorize" button in modal * simplified environment a bit Signed-off-by: Thomas Jaeckle --- ui/index.css | 4 + ui/modules/api.js | 29 +++-- ui/modules/environments/authorization.html | 126 ++++++++++++--------- ui/modules/environments/authorization.js | 56 ++++++--- ui/templates/environmentTemplates.json | 23 ++-- 5 files changed, 148 insertions(+), 90 deletions(-) diff --git a/ui/index.css b/ui/index.css index 0f725c5f5e..347968dbfe 100644 --- a/ui/index.css +++ b/ui/index.css @@ -46,6 +46,10 @@ body { padding-top: 60px; } +#authorizationModal label { + display: inline; +} + .toast-header { color: #842029; background-color: #f8d7da; diff --git a/ui/modules/api.js b/ui/modules/api.js index cdadd62a39..eb343316f2 100644 --- a/ui/modules/api.js +++ b/ui/modules/api.js @@ -277,18 +277,25 @@ let authHeaderValue; * @param {boolean} forDevOps if true, the credentials for the dev ops api will be used. */ export function setAuthHeader(forDevOps) { - if (forDevOps && Environments.current().useBasicAuth) { - authHeaderKey = 'Authorization'; - authHeaderValue = 'Basic ' + window.btoa(Environments.current().usernamePasswordDevOps); - } else if (Environments.current().useBasicAuth) { - authHeaderKey = 'Authorization'; - authHeaderValue = 'Basic ' + window.btoa(Environments.current().usernamePassword); - } else if (Environments.current().useDittoPreAuthenticatedAuth) { - authHeaderKey = 'x-ditto-pre-authenticated'; - authHeaderValue = Environments.current().dittoPreAuthenticatedUsername; + if (forDevOps) { + if (Environments.current().devopsAuth === 'basic') { + authHeaderKey = 'Authorization'; + authHeaderValue = 'Basic ' + window.btoa(Environments.current().usernamePasswordDevOps); + } else if (Environments.current().devopsAuth === 'bearer') { + authHeaderKey = 'Authorization'; + authHeaderValue ='Bearer ' + Environments.current().bearerDevOps; + } } else { - authHeaderKey = 'Authorization'; - authHeaderValue ='Bearer ' + Environments.current().bearer; + if (Environments.current().mainAuth === 'basic') { + authHeaderKey = 'Authorization'; + authHeaderValue = 'Basic ' + window.btoa(Environments.current().usernamePassword); + } else if (Environments.current().mainAuth === 'pre') { + authHeaderKey = 'x-ditto-pre-authenticated'; + authHeaderValue = Environments.current().dittoPreAuthenticatedUsername; + } else if (Environments.current().mainAuth === 'bearer') { + authHeaderKey = 'Authorization'; + authHeaderValue ='Bearer ' + Environments.current().bearer; + } } } diff --git a/ui/modules/environments/authorization.html b/ui/modules/environments/authorization.html index 91637f2fe0..ef3a0b8848 100644 --- a/ui/modules/environments/authorization.html +++ b/ui/modules/environments/authorization.html @@ -18,78 +18,94 @@