mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Rename AllowEverythingAuthorizer to AllowAllAuthorizer
This commit is contained in:
parent
971018cdec
commit
dee382849d
@ -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
|
||||
|
@ -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
|
||||
|
@ -7,7 +7,7 @@
|
||||
"Always allows all operations."
|
||||
],
|
||||
"@id": "urn:solid-server:default:Authorizer",
|
||||
"@type": "AllowEverythingAuthorizer"
|
||||
"@type": "AllowAllAuthorizer"
|
||||
}
|
||||
]
|
||||
}
|
@ -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<WebAclAuthorization> {
|
||||
return new WebAclAuthorization(allowEverything, allowEverything);
|
||||
return new WebAclAuthorization(allowAll, allowAll);
|
||||
}
|
||||
}
|
@ -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';
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
23
test/unit/authorization/AllowAllAuthorizer.test.ts
Normal file
23
test/unit/authorization/AllowAllAuthorizer.test.ts
Normal file
@ -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<void> => {
|
||||
await expect(authorizer.canHandle({} as any)).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('always returns a full access Authorization.', async(): Promise<void> => {
|
||||
await expect(authorizer.handle()).resolves.toEqual({
|
||||
user: allowAll,
|
||||
everyone: allowAll,
|
||||
});
|
||||
});
|
||||
});
|
@ -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<void> => {
|
||||
await expect(authorizer.canHandle({} as any)).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('always returns an empty Authorization.', async(): Promise<void> => {
|
||||
await expect(authorizer.handle()).resolves.toEqual({
|
||||
user: allowEverything,
|
||||
everyone: allowEverything,
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user