Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Permissions based on identity and new identity providers #31

Merged
merged 1 commit into from May 15, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -40,7 +40,7 @@
"ipfs-repo": "^0.26.1",
"ipfsd-ctl": "^0.40.3",
"mocha": "^5.2.0",
"orbit-db": "next",
"orbit-db": "0.20.0",
"orbit-db-identity-provider": "~0.1.0",
"orbit-db-keystore": "~0.2.0",
"standard": "^12.0.1",
Expand Down
8 changes: 4 additions & 4 deletions src/ipfs-access-controller.js
Expand Up @@ -20,14 +20,14 @@ class IPFSAccessController extends AccessController {

async canAppend (entry, identityProvider) {
// Allow if access list contain the writer's publicKey or is '*'
const publicKey = entry.v === 0 ? entry.key : entry.identity.publicKey
if (this.write.includes(publicKey) ||
this.write.includes('*')) {
return true
const publicKey = entry.v === 0 ? entry.key : entry.identity.id
if (this.write.includes(publicKey) || this.write.includes('*')) {
return entry.v === 1 ? await identityProvider.verifyIdentity(entry.identity) : true
}
return false
}


async load (address) {
// Transform '/ipfs/QmPFtHi3cmfZerxtH9ySLdzpg1yFhocYDZgEZywdUXHxFU'
// to 'QmPFtHi3cmfZerxtH9ySLdzpg1yFhocYDZgEZywdUXHxFU'
Expand Down
4 changes: 2 additions & 2 deletions src/orbitdb-access-controller.js
Expand Up @@ -27,7 +27,7 @@ class OrbitDBAccessController extends AccessController {
// Write keys and admins keys are allowed
const access = new Set([...this.get('write'), ...this.get('admin')])
// If the ACL contains the writer's public key or it contains '*'
if (access.has(entry.identity.publicKey) || access.has('*')) {
if (access.has(entry.identity.id) || access.has('*')) {
const verifiedIdentity = await identityProvider.verifyIdentity(entry.identity)
// Allow access if identity verifies
return verifiedIdentity
Expand Down Expand Up @@ -76,7 +76,7 @@ class OrbitDBAccessController extends AccessController {
// use ipfs controller as a immutable "root controller"
accessController: {
type: 'ipfs',
write: this._options.admin || [this._orbitdb.identity.publicKey]
write: this._options.admin || [this._orbitdb.identity.id]
},
sync: true
})
Expand Down