forked from solidcouch/solidcouch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(security): integrate joining community via Solid community inbox…
… service (solidcouch#131) Compatible with https://github.com/solidcouch/community-inbox/releases/tag/v0.3.1 Joining happens by POSTing "Join" activity to the community inbox. The inbox endpoint must be linked from the community URI via `ldp:inbox`. The inbox service must have read and write access to the relevant groups. We are introducing a new, safer mechanism for joining: Authenticated agents no longer require Append access to the relevant groups. This Append access is a security vulnerability and should be removed. This work also opens a possibility for leaving the community (TODO).
- Loading branch information
Showing
37 changed files
with
371 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { acl } from 'rdf-namespaces' | ||
|
||
interface AclConfig { | ||
permissions: ('Read' | 'Write' | 'Append' | 'Control')[] | ||
identifier?: string | ||
agents?: string[] | ||
agentGroups?: string[] | ||
agentClasses?: string[] | ||
isDefault?: boolean | ||
} | ||
|
||
const generateAuthorization = (resource: string, config: AclConfig) => { | ||
config.identifier ??= config.permissions.join('') | ||
const { | ||
permissions, | ||
agents, | ||
agentGroups, | ||
agentClasses, | ||
isDefault, | ||
identifier, | ||
} = config | ||
|
||
return `<#${identifier}> a <${acl.Authorization}>; | ||
${ | ||
agents && agents.length > 0 | ||
? `<${acl.agent}> ${agents.map(a => `<${a}>`).join(', ')};` | ||
: '' | ||
} | ||
${ | ||
agentGroups && agentGroups.length > 0 | ||
? `<${acl.agentGroup}> ${agentGroups.map(a => `<${a}>`).join(', ')};` | ||
: '' | ||
} | ||
${ | ||
agentClasses && agentClasses.length > 0 | ||
? `<${acl.agentClass}> ${agentClasses.map(a => `<${a}>`).join(', ')};` | ||
: '' | ||
} | ||
<${acl.accessTo}> <${resource}>; | ||
${isDefault ? `<${acl.default__workaround}> <${resource}>;` : ''} | ||
<${acl.mode}> ${permissions.map(p => `<${acl[p]}>`).join(', ')}.` | ||
} | ||
|
||
export const generateAcl = (resource: string, acls: AclConfig[]) => | ||
acls.map(config => generateAuthorization(resource, config)).join('\n\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.