Skip to content

Commit

Permalink
Merge 8f030e1 into 0200949
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserf committed Sep 9, 2019
2 parents 0200949 + 8f030e1 commit 3747e46
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
16 changes: 16 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,19 @@
## [4.2.0] - 2019.09.09

### Feat

Two new connection endpoints have been added. They are currently experimental and will be properly
announced with associated documentation.

One endpoint is mqtt! This allows us to support mqtt auth (using username and password), retain using records and QoS 1 using write acks. The only issue is since mqtt only supports one sort
of concept (with flags distinguishing them) we bridge both events and records together. That means if you subscribe to 'temperature/london', you'll get the update from both a client doing `event.emit('temperature/london')` and `record.setData('temperature/london')`.

The second endpoint is `ws-json` which allows users to interact with deepstream by just passing through json serialized text blobs instead of protobuf. This is mainly to help a few people trying to write SDKs without the hassle of a protobuf layer.

### Fix

Subscription registry seemed to have a massive leak when it came to dead sockets! This has now been fixed. The sockets seemed to have gotten the remove event deleted earlier in their lifecycle which prohibited it from doing a proper clean up later.

## [4.1.0] - 2019.08.30

### Feat
Expand Down
16 changes: 16 additions & 0 deletions src/services/permission/valve/config-permission-basic.spec.ts
Expand Up @@ -75,6 +75,22 @@ describe('permission handler applies basic permissions to incoming messages', ()
expect(testPermission(permissions, message, 'userA')).to.equal(true)
})

it('can reference the name', () => {
const permissions = getBasePermissions()

permissions.record['private/userA'] = {
read: 'name === "private/userA"'
}

const message = {
topic: C.TOPIC.RECORD,
action: C.RECORD_ACTION.READ,
name: 'private/userA'
}

expect(testPermission(permissions, message, 'userA')).to.equal(true)
})

it('denies snapshot of a private record', () => {
const permissions = getBasePermissions()

Expand Down
Expand Up @@ -144,6 +144,30 @@ describe('permission handler loads data for cross referencing', () => {
testPermission(permissions, message, null, null, onDone)
})

it('retrieves keys from name', (next) => {
const permissions = getBasePermissions()

services.cache.set('some-event', 0, { firstname: 'Joe' }, noop)

permissions.event['some-event'] = {
publish: '_(name).firstname === "Joe"'
}

const message = {
topic: C.TOPIC.EVENT,
action: C.EVENT_ACTION.EMIT,
name: 'some-event'
}

const callback = function (socketWrapper, msg, passItOn, error, result) {
expect(error).to.equal(null)
expect(result).to.equal(true)
next()
}

testPermission(permissions, message, 'username', null, callback)
})

it('retrieves keys from variables', (next) => {
const permissions = getBasePermissions()

Expand Down
1 change: 1 addition & 0 deletions src/services/permission/valve/rule-application.ts
Expand Up @@ -268,6 +268,7 @@ export default class RuleApplication {
this.getOldData(),
Date.now(),
this.params ? this.params.action : null,
this.params ? this.params.name : null
].concat(this.pathVars)
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/permission/valve/rule-parser.ts
Expand Up @@ -95,7 +95,7 @@ export const parse = (rule: boolean | string, variables: any) => {
}
}
const ruleObj: any = {}
const args = ['_', 'user', 'data', 'oldData', 'now', 'action'].concat(variables)
const args = ['_', 'user', 'data', 'oldData', 'now', 'action', 'name'].concat(variables)
args.push(`return ${rule};`)

ruleObj.fn = Function.apply(null, args)
Expand Down

0 comments on commit 3747e46

Please sign in to comment.