From d233df91bece21878e92ebe456755a186092c1f7 Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Sun, 8 Sep 2024 16:38:40 -0400 Subject: [PATCH] remove vanilla authorize owner --- src/core/auth.ts | 18 +----------------- src/core/dwn-error.ts | 1 - tests/interfaces/messages-subscribe.spec.ts | 4 ---- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/core/auth.ts b/src/core/auth.ts index 852e1bb68..68f67c9ef 100644 --- a/src/core/auth.ts +++ b/src/core/auth.ts @@ -34,20 +34,4 @@ export async function authenticate(authorizationModel: AuthorizationModel | unde const ownerDelegatedGrant = await RecordsWrite.parse(authorizationModel.ownerDelegatedGrant); await GeneralJwsVerifier.verifySignatures(ownerDelegatedGrant.message.authorization.signature, didResolver); } -} - -/** - * Authorizes owner authored message. - * @throws {DwnError} if fails authorization. - */ -export async function authorizeOwner(tenant: string, incomingMessage: MessageInterface): Promise { - // if author is the same as the target tenant, we can directly grant access - if (incomingMessage.author === tenant) { - return; - } else { - throw new DwnError( - DwnErrorCode.AuthorizationAuthorNotOwner, - `Message authored by ${incomingMessage.author}, not authored by expected owner ${tenant}.` - ); - } -} +} \ No newline at end of file diff --git a/src/core/dwn-error.ts b/src/core/dwn-error.ts index 0e8c299fe..c7ca8130d 100644 --- a/src/core/dwn-error.ts +++ b/src/core/dwn-error.ts @@ -16,7 +16,6 @@ export enum DwnErrorCode { AuthenticateJwsMissing = 'AuthenticateJwsMissing', AuthenticateDescriptorCidMismatch = 'AuthenticateDescriptorCidMismatch', AuthenticationMoreThanOneSignatureNotSupported = 'AuthenticationMoreThanOneSignatureNotSupported', - AuthorizationAuthorNotOwner = 'AuthorizationAuthorNotOwner', AuthorizationNotGrantedToAuthor = 'AuthorizationNotGrantedToAuthor', ComputeCidCodecNotSupported = 'ComputeCidCodecNotSupported', ComputeCidMultihashNotSupported = 'ComputeCidMultihashNotSupported', diff --git a/tests/interfaces/messages-subscribe.spec.ts b/tests/interfaces/messages-subscribe.spec.ts index 096946ad3..8755c1504 100644 --- a/tests/interfaces/messages-subscribe.spec.ts +++ b/tests/interfaces/messages-subscribe.spec.ts @@ -1,4 +1,3 @@ -import { authorizeOwner } from '../../src/core/auth.js'; import { MessagesSubscribe } from '../../src/interfaces/messages-subscribe.js'; import { DwnInterfaceName, DwnMethodName, Jws, TestDataGenerator, Time } from '../../src/index.js'; @@ -19,9 +18,6 @@ describe('MessagesSubscribe', () => { expect(message.descriptor.method).to.eql(DwnMethodName.Subscribe); expect(message.authorization).to.exist; expect(message.descriptor.messageTimestamp).to.equal(timestamp); - - // MessagesSubscribe authorizes against owner - await authorizeOwner(alice.did, messagesSubscribe); }); }); });