-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add authenticated proxy support (WEBAPP-6412) (backport) (#3131)
- Loading branch information
Showing
9 changed files
with
453 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2019 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
html { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
body { | ||
align-items: center; | ||
background-color: #fff; | ||
color: #34383b; | ||
cursor: default; | ||
display: flex; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Helvetica, Arial, sans-serif; | ||
font-size: 14px; | ||
height: 100%; | ||
justify-content: center; | ||
margin: 0; | ||
padding: 0; | ||
text-align: center; | ||
width: 100%; | ||
} | ||
|
||
#container { | ||
} | ||
|
||
#form { | ||
width: 100%; | ||
} | ||
|
||
h1 { | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||
font-weight: 300; | ||
} | ||
|
||
p { | ||
margin: 0 0 16px; | ||
} | ||
|
||
label { | ||
display: inline-block; | ||
width: 80px; | ||
text-align: right; | ||
margin-right: 8px; | ||
} | ||
|
||
input { | ||
padding: 0.5em; | ||
border-radius: 4px; | ||
border: 1px solid #bac8d1; | ||
width: 160px; | ||
font-size: 14px; | ||
} | ||
|
||
button { | ||
cursor: pointer; | ||
border-radius: 2px; | ||
margin: 0 4px; | ||
border: 0; | ||
line-height: 1em; | ||
padding: 8px 8px; | ||
width: 80px; | ||
font-size: 12px; | ||
} | ||
.copy { | ||
margin-bottom: 16px; | ||
padding-bottom: 16px; | ||
border-bottom: 1px solid #e1e7eb; | ||
} | ||
|
||
.buttons { | ||
margin-top: 16px; | ||
padding-top: 16px; | ||
border-top: 1px solid #e1e7eb; | ||
} | ||
|
||
#okButton { | ||
background-color: #3879d9; | ||
color: white; | ||
} | ||
|
||
#cancelButton { | ||
background-color: #ddd; | ||
color: black; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<!-- Wire, Copyright (C) 2019 Wire Swiss GmbH --> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../css/proxy-prompt.css" /> | ||
</head> | ||
<body> | ||
<div id="container" data-uie-name="proxy"> | ||
<form id="form"> | ||
<h1 data-string="proxyPromptTitle"></h1> | ||
<p class="copy"><span data-string="proxyPromptHeadline"></span></p> | ||
<p> | ||
<label for="usernameInput" data-string="proxyPromptUsername" data-uie-name="input-username"></label> | ||
<input type="text" id="usernameInput" /> | ||
</p> | ||
<p> | ||
<label for="passwordInput" data-string="proxyPromptPassword" data-uie-name="input-password"></label> | ||
<input type="password" id="passwordInput" /> | ||
</p> | ||
<p class="buttons"> | ||
<button id="cancelButton" data-string="proxyPromptCancel" data-uie-name="do-cancel" type="reset"></button> | ||
<button id="okButton" data-string="proxyPromptOk" data-uie-name="do-ok" type="submit"></button> | ||
</p> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2019 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {IpcMessageEvent, ipcRenderer} from 'electron'; | ||
|
||
import {EVENT_TYPE} from '../../lib/eventType'; | ||
|
||
ipcRenderer.once(EVENT_TYPE.PROXY_PROMPT.LOCALE_RENDER, (event: IpcMessageEvent, labels: string[]) => { | ||
for (const label in labels) { | ||
const labelElement = document.querySelector(`[data-string="${label}"]`); | ||
if (labelElement) { | ||
labelElement.innerHTML = labels[label]; | ||
} | ||
} | ||
}); | ||
|
||
ipcRenderer.once(EVENT_TYPE.PROXY_PROMPT.LOADED, () => { | ||
const labels = []; | ||
const dataStrings = document.querySelectorAll<HTMLDivElement>('[data-string]'); | ||
|
||
for (const index in dataStrings) { | ||
const label = dataStrings[index]; | ||
if (label.dataset) { | ||
labels.push(label.dataset.string); | ||
} | ||
} | ||
|
||
ipcRenderer.send(EVENT_TYPE.PROXY_PROMPT.LOCALE_VALUES, labels); | ||
|
||
const okButton = document.querySelector<HTMLButtonElement>('#okButton'); | ||
const cancelButton = document.querySelector<HTMLButtonElement>('#cancelButton'); | ||
const usernameInput = document.querySelector<HTMLInputElement>('#usernameInput'); | ||
const passwordInput = document.querySelector<HTMLInputElement>('#passwordInput'); | ||
const form = document.querySelector<HTMLInputElement>('#form'); | ||
|
||
if (cancelButton && okButton && usernameInput && passwordInput && form) { | ||
usernameInput.focus(); | ||
|
||
const sendData = () => { | ||
ipcRenderer.send(EVENT_TYPE.PROXY_PROMPT.SUBMITTED, { | ||
password: passwordInput.value, | ||
username: usernameInput.value, | ||
}); | ||
window.close(); | ||
}; | ||
|
||
cancelButton.addEventListener('click', () => { | ||
ipcRenderer.send(EVENT_TYPE.PROXY_PROMPT.CANCELED); | ||
window.close(); | ||
}); | ||
|
||
form.addEventListener('submit', () => sendData()); | ||
|
||
window.addEventListener('keydown', event => { | ||
if (event.key === 'Escape') { | ||
ipcRenderer.send(EVENT_TYPE.PROXY_PROMPT.CANCELED); | ||
window.close(); | ||
} | ||
}); | ||
} | ||
}); |
Oops, something went wrong.