diff --git a/config/README.md b/config/README.md index 468b4c8d7..6dca90572 100644 --- a/config/README.md +++ b/config/README.md @@ -11,7 +11,7 @@ it is always possible to not choose any of them and create your own custom versi # How to use The easiest way to create a new config is by creating a JSON-LD file that imports one option from every component subfolder -(such as either `allow-everything.json` or `webacl.json` from `ldp/authorization`). +(such as either `allow-all.json` or `webacl.json` from `ldp/authorization`). In case none of the available options suffice, there are 2 other ways to handle this: ## Append to an existing config diff --git a/config/ldp/README.md b/config/ldp/README.md index 561fca860..9642a64b4 100644 --- a/config/ldp/README.md +++ b/config/ldp/README.md @@ -11,7 +11,7 @@ Covers how agents are identified. ## Authorization Covers how operations are authorized (or rejected). -* *allow-everything*: No authorization, everything is allowed. +* *allow-all*: No authorization, everything is allowed. * *webacl*: Use the default Web Access Control. ## Handler diff --git a/config/ldp/authorization/allow-everything.json b/config/ldp/authorization/allow-all.json similarity index 89% rename from config/ldp/authorization/allow-everything.json rename to config/ldp/authorization/allow-all.json index a6dfb8e0a..141b64894 100644 --- a/config/ldp/authorization/allow-everything.json +++ b/config/ldp/authorization/allow-all.json @@ -7,7 +7,7 @@ "Always allows all operations." ], "@id": "urn:solid-server:default:Authorizer", - "@type": "AllowEverythingAuthorizer" + "@type": "AllowAllAuthorizer" } ] } diff --git a/src/authorization/AllowEverythingAuthorizer.ts b/src/authorization/AllowAllAuthorizer.ts similarity index 70% rename from src/authorization/AllowEverythingAuthorizer.ts rename to src/authorization/AllowAllAuthorizer.ts index 7344d1a0c..12a2a12dc 100644 --- a/src/authorization/AllowEverythingAuthorizer.ts +++ b/src/authorization/AllowAllAuthorizer.ts @@ -2,7 +2,7 @@ import type { PermissionSet } from '../ldp/permissions/PermissionSet'; import { Authorizer } from './Authorizer'; import { WebAclAuthorization } from './WebAclAuthorization'; -const allowEverything: PermissionSet = { +const allowAll: PermissionSet = { read: true, write: true, append: true, @@ -12,8 +12,8 @@ const allowEverything: PermissionSet = { /** * Authorizer which allows all access independent of the identifier and requested permissions. */ -export class AllowEverythingAuthorizer extends Authorizer { +export class AllowAllAuthorizer extends Authorizer { public async handle(): Promise { - return new WebAclAuthorization(allowEverything, allowEverything); + return new WebAclAuthorization(allowAll, allowAll); } } diff --git a/src/index.ts b/src/index.ts index aa95300a2..80c039132 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ export * from './authentication/UnsecureConstantCredentialsExtractor'; export * from './authentication/UnsecureWebIdExtractor'; // Authorization -export * from './authorization/AllowEverythingAuthorizer'; +export * from './authorization/AllowAllAuthorizer'; export * from './authorization/Authorization'; export * from './authorization/Authorizer'; export * from './authorization/AuxiliaryAuthorizer'; diff --git a/test/integration/config/run-with-redlock.json b/test/integration/config/run-with-redlock.json index 55b925291..9b902ce03 100644 --- a/test/integration/config/run-with-redlock.json +++ b/test/integration/config/run-with-redlock.json @@ -8,7 +8,7 @@ "files-scs:config/http/server-factory/no-websockets.json", "files-scs:config/http/static/default.json", "files-scs:config/ldp/authentication/debug-auth-header.json", - "files-scs:config/ldp/authorization/allow-everything.json", + "files-scs:config/ldp/authorization/allow-all.json", "files-scs:config/ldp/handler/default.json", "files-scs:config/ldp/metadata-parser/default.json", "files-scs:config/ldp/metadata-writer/default.json", diff --git a/test/integration/config/server-without-auth.json b/test/integration/config/server-without-auth.json index 3c8a32110..7cd7a4ab4 100644 --- a/test/integration/config/server-without-auth.json +++ b/test/integration/config/server-without-auth.json @@ -8,7 +8,7 @@ "files-scs:config/http/server-factory/websockets.json", "files-scs:config/http/static/default.json", "files-scs:config/ldp/authentication/dpop-bearer.json", - "files-scs:config/ldp/authorization/allow-everything.json", + "files-scs:config/ldp/authorization/allow-all.json", "files-scs:config/ldp/handler/default.json", "files-scs:config/ldp/metadata-parser/default.json", "files-scs:config/ldp/metadata-writer/default.json", diff --git a/test/unit/authorization/AllowAllAuthorizer.test.ts b/test/unit/authorization/AllowAllAuthorizer.test.ts new file mode 100644 index 000000000..e55366d90 --- /dev/null +++ b/test/unit/authorization/AllowAllAuthorizer.test.ts @@ -0,0 +1,23 @@ +import { AllowAllAuthorizer } from '../../../src/authorization/AllowAllAuthorizer'; +import type { PermissionSet } from '../../../src/ldp/permissions/PermissionSet'; + +describe('An AllowAllAuthorizer', (): void => { + const authorizer = new AllowAllAuthorizer(); + const allowAll: PermissionSet = { + read: true, + write: true, + append: true, + control: true, + }; + + it('can handle everything.', async(): Promise => { + await expect(authorizer.canHandle({} as any)).resolves.toBeUndefined(); + }); + + it('always returns a full access Authorization.', async(): Promise => { + await expect(authorizer.handle()).resolves.toEqual({ + user: allowAll, + everyone: allowAll, + }); + }); +}); diff --git a/test/unit/authorization/AllowEverythingAuthorizer.test.ts b/test/unit/authorization/AllowEverythingAuthorizer.test.ts deleted file mode 100644 index 3c0f8d4a0..000000000 --- a/test/unit/authorization/AllowEverythingAuthorizer.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { AllowEverythingAuthorizer } from '../../../src/authorization/AllowEverythingAuthorizer'; -import type { PermissionSet } from '../../../src/ldp/permissions/PermissionSet'; - -describe('An AllowEverythingAuthorizer', (): void => { - const authorizer = new AllowEverythingAuthorizer(); - const allowEverything: PermissionSet = { - read: true, - write: true, - append: true, - control: true, - }; - - it('can handle everything.', async(): Promise => { - await expect(authorizer.canHandle({} as any)).resolves.toBeUndefined(); - }); - - it('always returns an empty Authorization.', async(): Promise => { - await expect(authorizer.handle()).resolves.toEqual({ - user: allowEverything, - everyone: allowEverything, - }); - }); -});