Skip to content

Commit

Permalink
Backed out 14 changesets (bug 1782080, bug 1782083, bug 1782085, bug …
Browse files Browse the repository at this point in the history
…1782081) for causing bp-hybrid bustage. CLOSED TREE

Backed out changeset 2b4331989f86 (bug 1782085)
Backed out changeset 582f58cd75cc (bug 1782085)
Backed out changeset c1de76ba8d99 (bug 1782085)
Backed out changeset 547eaff150f2 (bug 1782085)
Backed out changeset e56983c42821 (bug 1782085)
Backed out changeset c4682175eeaa (bug 1782085)
Backed out changeset 6b28de5c2f9d (bug 1782085)
Backed out changeset cb6218ad0b48 (bug 1782085)
Backed out changeset 48b8f947094e (bug 1782085)
Backed out changeset 754f27150336 (bug 1782085)
Backed out changeset c733035b2995 (bug 1782085)
Backed out changeset 1006a551ba12 (bug 1782083)
Backed out changeset 099f10b82184 (bug 1782081)
Backed out changeset 1cf5eecc663b (bug 1782080)
  • Loading branch information
Sandor Molnar committed Sep 13, 2022
1 parent d0450b3 commit 3e3ce5f
Show file tree
Hide file tree
Showing 51 changed files with 23 additions and 2,152 deletions.
121 changes: 17 additions & 104 deletions dom/credentialmanagement/CredentialsContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/dom/Credential.h"
#include "mozilla/dom/CredentialsContainer.h"
#include "mozilla/dom/IdentityCredential.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/StaticPrefs_security.h"
#include "mozilla/dom/WebAuthnManager.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/dom/WindowContext.h"
#include "nsContentUtils.h"
#include "nsFocusManager.h"
#include "nsIDocShell.h"
#include "nsGlobalWindowInner.h"

namespace mozilla::dom {

Expand All @@ -27,42 +23,22 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CredentialsContainer)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END

already_AddRefed<Promise> CreatePromise(nsPIDOMWindowInner* aParent,
ErrorResult& aRv) {
already_AddRefed<Promise> CreateAndReject(nsPIDOMWindowInner* aParent,
ErrorResult& aRv) {
MOZ_ASSERT(aParent);

nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aParent);
if (NS_WARN_IF(!global)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}

RefPtr<Promise> promise = Promise::Create(global, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
return promise.forget();
}

already_AddRefed<Promise> CreateAndRejectWithNotAllowed(
nsPIDOMWindowInner* aParent, ErrorResult& aRv) {
MOZ_ASSERT(aParent);
RefPtr<Promise> promise = CreatePromise(aParent, aRv);
if (!promise) {
return nullptr;
}
promise->MaybeRejectWithNotAllowedError(
"CredentialContainer request is not allowed."_ns);
return promise.forget();
}

already_AddRefed<Promise> CreateAndRejectWithNotSupported(
nsPIDOMWindowInner* aParent, ErrorResult& aRv) {
MOZ_ASSERT(aParent);
RefPtr<Promise> promise = CreatePromise(aParent, aRv);
if (!promise) {
return nullptr;
}
promise->MaybeRejectWithNotSupportedError(
"CredentialContainer request is not supported."_ns);
promise->MaybeReject(NS_ERROR_DOM_NOT_ALLOWED_ERR);
return promise.forget();
}

Expand Down Expand Up @@ -130,95 +106,32 @@ JSObject* CredentialsContainer::WrapObject(JSContext* aCx,

already_AddRefed<Promise> CredentialsContainer::Get(
const CredentialRequestOptions& aOptions, ErrorResult& aRv) {
uint64_t totalOptions = 0;
if (aOptions.mPublicKey.WasPassed() &&
StaticPrefs::security_webauth_webauthn()) {
totalOptions += 1;
}
if (aOptions.mIdentity.WasPassed() &&
StaticPrefs::dom_security_credentialmanagement_identity_enabled()) {
totalOptions += 1;
}
if (totalOptions > 1) {
return CreateAndRejectWithNotSupported(mParent, aRv);
}

if (aOptions.mPublicKey.WasPassed() &&
StaticPrefs::security_webauth_webauthn()) {
if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) {
return CreateAndRejectWithNotAllowed(mParent, aRv);
}

EnsureWebAuthnManager();
return mManager->GetAssertion(aOptions.mPublicKey.Value(), aOptions.mSignal,
aRv);
}

if (aOptions.mIdentity.WasPassed() &&
StaticPrefs::dom_security_credentialmanagement_identity_enabled()) {
RefPtr<Promise> promise = CreatePromise(mParent, aRv);

IdentityCredential::DiscoverFromExternalSource(
mParent, aOptions, IsSameOriginWithAncestors(mParent))
->Then(
GetCurrentSerialEventTarget(), __func__,
[promise](RefPtr<IdentityCredential> credential) {
promise->MaybeResolve(credential);
},
[promise](nsresult error) { promise->MaybeReject(error); });

return promise.forget();
if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) {
return CreateAndReject(mParent, aRv);
}

return CreateAndRejectWithNotSupported(mParent, aRv);
EnsureWebAuthnManager();
return mManager->GetAssertion(aOptions.mPublicKey, aOptions.mSignal, aRv);
}

already_AddRefed<Promise> CredentialsContainer::Create(
const CredentialCreationOptions& aOptions, ErrorResult& aRv) {
// Count the types of options provided. Must not be >1.
uint64_t totalOptions = 0;
if (aOptions.mPublicKey.WasPassed() &&
StaticPrefs::security_webauth_webauthn()) {
totalOptions += 1;
}
if (totalOptions > 1) {
return CreateAndRejectWithNotSupported(mParent, aRv);
if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) {
return CreateAndReject(mParent, aRv);
}

if (aOptions.mPublicKey.WasPassed() &&
StaticPrefs::security_webauth_webauthn()) {
if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) {
return CreateAndRejectWithNotAllowed(mParent, aRv);
}

EnsureWebAuthnManager();
return mManager->MakeCredential(aOptions.mPublicKey.Value(),
aOptions.mSignal, aRv);
}

return CreateAndRejectWithNotSupported(mParent, aRv);
EnsureWebAuthnManager();
return mManager->MakeCredential(aOptions.mPublicKey, aOptions.mSignal, aRv);
}

already_AddRefed<Promise> CredentialsContainer::Store(
const Credential& aCredential, ErrorResult& aRv) {
nsString type;
aCredential.GetType(type);
if (type.EqualsLiteral("public-key") &&
StaticPrefs::security_webauth_webauthn()) {
if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) {
return CreateAndRejectWithNotAllowed(mParent, aRv);
}

EnsureWebAuthnManager();
return mManager->Store(aCredential, aRv);
}

if (type.EqualsLiteral("identity") &&
StaticPrefs::dom_security_credentialmanagement_identity_enabled()) {
return CreateAndRejectWithNotSupported(mParent, aRv);
if (!IsSameOriginWithAncestors(mParent) || !IsInActiveTab(mParent)) {
return CreateAndReject(mParent, aRv);
}

return CreateAndRejectWithNotSupported(mParent, aRv);
EnsureWebAuthnManager();
return mManager->Store(aCredential, aRv);
}

already_AddRefed<Promise> CredentialsContainer::PreventSilentAccess(
Expand Down
18 changes: 0 additions & 18 deletions dom/credentialmanagement/identity/IPCIdentityCredential.ipdlh

This file was deleted.

Loading

0 comments on commit 3e3ce5f

Please sign in to comment.