mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Allow CSP connect-src CORS for keys.openpgp.org to directly fetch PGP keys
This commit is contained in:
parent
bfb0874c47
commit
62f0bac381
3 changed files with 25 additions and 2 deletions
|
|
@ -32,7 +32,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
|
|
||||||
searchPGP() {
|
searchPGP() {
|
||||||
this.key(i18n('SUGGESTIONS/SEARCHING_DESC'));
|
this.key(i18n('SUGGESTIONS/SEARCHING_DESC'));
|
||||||
Remote.request('SearchPGPKey',
|
const fn = () => Remote.request('SearchPGPKey',
|
||||||
(iError, oData) => {
|
(iError, oData) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
this.key(oData.ErrorMessage);
|
this.key(oData.ErrorMessage);
|
||||||
|
|
@ -43,6 +43,29 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
query: this.search()
|
query: this.search()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
fetch(
|
||||||
|
`https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=${this.search()}`,
|
||||||
|
{
|
||||||
|
method: 'GET',
|
||||||
|
mode: 'cors',
|
||||||
|
cache: 'no-cache',
|
||||||
|
redirect: 'error',
|
||||||
|
referrerPolicy: 'no-referrer',
|
||||||
|
credentials: 'omit'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(response => {
|
||||||
|
if ('application/pgp-keys' == response.headers.get('Content-Type')) {
|
||||||
|
response.text().then(body => this.key(body));
|
||||||
|
} else {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
this.key('keys.openpgp.org: ' + e?.message + '\nTrying local...');
|
||||||
|
fn();
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
submitForm() {
|
submitForm() {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class CSP
|
||||||
'img-src' => ["'self'", 'data:'],
|
'img-src' => ["'self'", 'data:'],
|
||||||
'media-src' => ["'self'", 'data:'],
|
'media-src' => ["'self'", 'data:'],
|
||||||
'style-src' => ["'self'", "'unsafe-inline'"],
|
'style-src' => ["'self'", "'unsafe-inline'"],
|
||||||
|
'connect-src' => ["'self'", "keys.openpgp.org"]
|
||||||
];
|
];
|
||||||
|
|
||||||
function __construct(string $default = '')
|
function __construct(string $default = '')
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
value: saveServer
|
value: saveServer
|
||||||
}
|
}
|
||||||
}"></div>
|
}"></div>
|
||||||
<br>
|
|
||||||
<div data-bind="visible: canGnuPG, component: {
|
<div data-bind="visible: canGnuPG, component: {
|
||||||
name: 'Checkbox',
|
name: 'Checkbox',
|
||||||
params: {
|
params: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue