mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Merge aea8ac548c into b01af22fd1
This commit is contained in:
commit
2014e79cd2
1 changed files with 18 additions and 4 deletions
|
|
@ -7,7 +7,8 @@ const PASSKEYS_WAIT_FOR_LIFETIMER = 30;
|
||||||
// Apply a script to the page for intercepting Passkeys (WebAuthn) requests
|
// Apply a script to the page for intercepting Passkeys (WebAuthn) requests
|
||||||
const enablePasskeys = async function() {
|
const enablePasskeys = async function() {
|
||||||
const passkeysLogDebug = function(message, extra) {
|
const passkeysLogDebug = function(message, extra) {
|
||||||
if (kpxcPasskeysUtils.debugLogging) {
|
// `global.js` runs at `document_idle`
|
||||||
|
if (kpxcPasskeysUtils.debugLogging && typeof debugLogMessage === 'function') {
|
||||||
debugLogMessage(message, extra);
|
debugLogMessage(message, extra);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -63,8 +64,21 @@ const enablePasskeys = async function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isSameOriginWithAncestors = function () {
|
/**
|
||||||
|
* @param {'create' | 'get'} action
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
const isAllowedByPolicy = function (action) {
|
||||||
|
// https://www.w3.org/TR/webauthn-2/#sctn-permissions-policy
|
||||||
|
const policy = document.featurePolicy || document.permissionsPolicy;
|
||||||
|
if (policy) {
|
||||||
|
passkeysLogDebug('Checking Permissions Policy');
|
||||||
|
return policy.allowsFeature(`publickey-credentials-${action}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback to sameOriginWithAncestors
|
||||||
try {
|
try {
|
||||||
|
passkeysLogDebug('Checking sameOriginWithAncestors');
|
||||||
return window.origin === window.top.origin;
|
return window.origin === window.top.origin;
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -80,14 +94,14 @@ const enablePasskeys = async function() {
|
||||||
if (ev.detail.action === 'passkeys_create') {
|
if (ev.detail.action === 'passkeys_create') {
|
||||||
const publicKey = kpxcPasskeysUtils.buildCredentialCreationOptions(
|
const publicKey = kpxcPasskeysUtils.buildCredentialCreationOptions(
|
||||||
ev.detail.publicKey,
|
ev.detail.publicKey,
|
||||||
isSameOriginWithAncestors(),
|
isAllowedByPolicy('create'),
|
||||||
);
|
);
|
||||||
passkeysLogDebug('Passkey request', publicKey);
|
passkeysLogDebug('Passkey request', publicKey);
|
||||||
await sendResponse('passkeys_register', publicKey);
|
await sendResponse('passkeys_register', publicKey);
|
||||||
} else if (ev.detail.action === 'passkeys_get') {
|
} else if (ev.detail.action === 'passkeys_get') {
|
||||||
const publicKey = kpxcPasskeysUtils.buildCredentialRequestOptions(
|
const publicKey = kpxcPasskeysUtils.buildCredentialRequestOptions(
|
||||||
ev.detail.publicKey,
|
ev.detail.publicKey,
|
||||||
isSameOriginWithAncestors(),
|
isAllowedByPolicy('get'),
|
||||||
);
|
);
|
||||||
passkeysLogDebug('Passkey request', publicKey);
|
passkeysLogDebug('Passkey request', publicKey);
|
||||||
await sendResponse('passkeys_get', publicKey);
|
await sendResponse('passkeys_get', publicKey);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue