Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 37 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solid-logic",
"version": "6.2.1-0",
"version": "6.2.1-1",
"description": "Core business logic of SolidOS",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
Expand Down
15 changes: 5 additions & 10 deletions src/acl/aclLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ import type { AclLogic } from '../types'
import { ns as namespace } from '../util/ns'
import * as accessControlSubjects from './accessControlSubjects'

export const ACCESS_ROLES = ['Owner', 'Editor', 'No Access', 'Viewer', 'Poster', 'Submitter'] as const
export const ACCESS_ROLES = ['Owner', 'Admin', 'Editor', 'No Access', 'Viewer', 'Commenter', 'Appender'] as const
export const PUBLIC_ACCESS_ROLES = ['No Access', 'Viewer'] as const
/**
* A Control grant without Write is the legacy "write locked" owner grant.
*
* It is intentionally not part of ACCESS_ROLES yet: that list is consumed by
* the existing UI, whose selector will be updated in a later change.
*/

export const WRITE_LOCKED_OWNER_ROLE = 'Owner (write locked)' as const
export { Authenticated, Public } from '@dokieli/web-access-control'

Expand Down Expand Up @@ -103,10 +98,10 @@ export function createAclLogic(store): AclLogic {
const ns = namespace
const ACCESS_ROLE_RULES: Array<{ label: AccessRole, modes: AccessMode[] }> = [
{ label: 'Owner', modes: ['Read', 'Write', 'Control'] },
{ label: WRITE_LOCKED_OWNER_ROLE, modes: ['Read', 'Control'] },
{ label: 'Admin', modes: ['Read', 'Control'] },
{ label: 'Editor', modes: ['Read', 'Write'] },
{ label: 'Poster', modes: ['Append', 'Read'] },
{ label: 'Submitter', modes: ['Append'] },
{ label: 'Commenter', modes: ['Append', 'Read'] },
{ label: 'Appender', modes: ['Append'] },
{ label: 'Viewer', modes: ['Read'] },
{ label: 'No Access', modes: [] }
]
Expand Down
9 changes: 4 additions & 5 deletions test/aclLogic.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { Fetcher, Store, literal, namedNode, sym, UpdateManager } from 'rdflib'
import { ACL, applyPlan, buildACLContext, findEffectiveACL, parseTurtle, planGrant, planPublicRead, planRevoke, Public, quad, type PatchPlan, type Quad } from '@dokieli/web-access-control'
import { ACL_LINK, WRITE_LOCKED_OWNER_ROLE, analyzeContainerAccessScope, classifyAuthorizationScope, classifyContainerAccessScope, createAclLogic, filterAuthorizationsByContainerScope } from '../src/acl/aclLogic'
import { ACL_LINK, analyzeContainerAccessScope, classifyAuthorizationScope, classifyContainerAccessScope, createAclLogic, filterAuthorizationsByContainerScope } from '../src/acl/aclLogic'

var actualFindEffectiveACL: typeof findEffectiveACL
var actualPlanGrant: typeof planGrant
Expand Down Expand Up @@ -165,16 +165,15 @@ describe('createAclLogic', () => {
it('maps roles to ACL modes and back', () => {
expect(aclLogic.modesFromRole('Editor')).toEqual(['Read', 'Write'])
expect(aclLogic.modesFromRole('Owner')).toEqual(['Read', 'Write', 'Control'])
expect(aclLogic.modesFromRole(WRITE_LOCKED_OWNER_ROLE)).toEqual(['Read', 'Control'])
expect(aclLogic.modesFromRole('No Access')).toEqual([])
expect(aclLogic.roleFromModes(['Read', 'Write'])).toBe('Editor')
expect(aclLogic.roleFromModes(['Read'])).toBe('Viewer')
expect(aclLogic.roleFromModes(['Control', 'Read'])).toBe(WRITE_LOCKED_OWNER_ROLE)
expect(aclLogic.roleFromModes(['Control', 'Read'])).toBe('Admin')
expect(aclLogic.roleFromModes(['Read', 'Write', 'Control', 'Append'])).toBe('No Access')
expect(aclLogic.roleFromModes([])).toBe('No Access')
})

it('preserves write-locked owner modes in a grant plan', async () => {
it('plans admin modes without write access', async () => {
const resource = 'https://example.com/write-locked.ttl'
const ownACL = `@prefix acl: <${ACL}>.
<#existing> a acl:Authorization;
Expand All @@ -184,7 +183,7 @@ describe('createAclLogic', () => {
const plan = await sharingLogic(resource, ownACL).planGrant(resource, {
type: 'agent',
iri: 'https://example.com/profile/card#owner'
}, aclLogic.modesFromRole(WRITE_LOCKED_OWNER_ROLE))
}, aclLogic.modesFromRole('Admin'))

expect(plan.inserts
.filter(statement => statement.predicate.value === ACL + 'mode')
Expand Down
2 changes: 1 addition & 1 deletion test/publicAclApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

describe('public ACL API', () => {
it('exports the role list and exposes mapping through the singleton', () => {
expect(ACCESS_ROLES).toEqual(['Owner', 'Editor', 'No Access', 'Viewer', 'Poster', 'Submitter'])
expect(ACCESS_ROLES).toEqual(['Owner', 'Admin', 'Editor', 'No Access', 'Viewer', 'Commenter', 'Appender'])
expect(PUBLIC_ACCESS_ROLES).toEqual(['No Access', 'Viewer'])
expect(WRITE_LOCKED_OWNER_ROLE).toBe('Owner (write locked)')
expect(Authenticated).toMatchObject({ type: 'agentClass', iri: 'http://www.w3.org/ns/auth/acl#AuthenticatedAgent' })
Expand Down
Loading