Alignment of permission schemas with ROS 2 (#1344)

* Alignment of permission schemas with ROS 2
This commit is contained in:
Kenneth Geisshirt 2017-09-26 11:23:36 +02:00 committed by GitHub
parent 41cecabe45
commit b676201e03
3 changed files with 53 additions and 54 deletions

View File

@ -9,6 +9,8 @@ X.Y.Z Release notes
### Bug fixes
* Fixed port conflict between RN >= 0.48 inspector proxy and RPC server used for Chrome debugging (#1294).
### Internal
* Alignment of permission schemas.
2.0.0-rc10 Release notes (2017-9-19)
=============================================================
@ -27,7 +29,7 @@ X.Y.Z Release notes
### Enhancements
* Improve performance of the RPC worker for chrome debugging.
* Added Progress API `realm.syncSession.addProgressNotification` and `realm.syncSession.removeProgressNotification`
* Added additional parameter for `Realm.open` and `Realm.openAsync` for download progress notifications
* Added additional parameter for `Realm.open` and `Realm.openAsync` for download progress notifications
* Added `Realm.deleteFile` for deleting a Realm (#363).
* Added `Realm.deleteModel` for deleting a Realm model in a migration (#573).
* Added support for in-memory Realms.
@ -162,7 +164,7 @@ X.Y.Z Release notes
* Added `indexOf()` method on `Realm.Results` and `Realm.List` that returns the index of the object in the collection.
### Bug fixes
* Fix opening synced realms with a logged-in admin user.
* Fix opening synced realms with a logged-in admin user.
1.8.1 Release notes (2017-6-20)
=============================================================
@ -176,7 +178,7 @@ X.Y.Z Release notes
* Added `objectSchema()` method on `Realm.Object` that returns the schema for the object.
### Bug fixes
* Fix `Realm.Sync.User.prototype.isAdmin` returning `false` for logged-in admin users.
* Fix `Realm.Sync.User.prototype.isAdmin` returning `false` for logged-in admin users.
1.8.0 Release notes (2017-6-15)
=============================================================

View File

@ -21,50 +21,50 @@
module.exports = [
{
name: 'PermissionChange',
primaryKey: 'id',
properties: {
id: { type: 'string' },
createdAt: { type: 'date' },
updatedAt: { type: 'date' },
statusCode: { type: 'int', optional: true },
statusMessage: { type: 'string', optional: true },
userId: { type: 'string' },
metadataKey: { type: 'string', optional: true },
id: {type: 'string'},
createdAt: {type: 'date', default: new Date()},
updatedAt: {type: 'date', default: new Date()},
statusCode: { type: 'int', optional: true },
statusMessage: {type: 'string', optional: true},
userId: { type: 'string' },
realmUrl: { type: 'string' },
metadataKey: { type: 'string', optional: true },
metadataValue: { type: 'string', optional: true },
realmUrl: { type: 'string' },
mayRead: { type: 'bool', optional: true },
mayWrite: { type: 'bool', optional: true },
mayManage: { type: 'bool', optional: true },
},
primaryKey: 'id'
mayRead: { type: 'bool', optional: true },
mayWrite: { type: 'bool', optional: true },
mayManage: { type: 'bool', optional: true },
}
},
{
name: 'PermissionOffer',
primaryKey: 'id',
properties: {
id: { type: 'string' },
createdAt: { type: 'date' },
updatedAt: { type: 'date' },
statusCode: { type: 'int', optional: true },
statusMessage: { type: 'string', optional: true },
token: { type: 'string', optional: true, indexed: true },
realmUrl: { type: 'string' },
mayRead: { type: 'bool', default: false },
mayWrite: { type: 'bool', default: false },
mayManage: { type: 'bool', default: false },
expiresAt: { type: 'date', optional: true },
},
primaryKey: 'id'
id: { type: 'string', optional: false, indexed: true },
createdAt: {type: 'date', default: new Date()},
updatedAt: {type: 'date', default: new Date()},
statusCode: { type: 'int', optional: true },
statusMessage: {type: 'string', optional: true},
token: { type: 'string', optional: true, indexed: true },
realmUrl: { type: 'string' },
mayRead: { type: 'bool', default: false },
mayWrite: { type: 'bool', default: false },
mayManage: { type: 'bool', default: false },
expiresAt: { type: 'date', optional: true }
}
},
{
name: 'PermissionOfferResponse',
primaryKey: 'id',
properties: {
id: { type: 'string' },
createdAt: { type: 'date' },
updatedAt: { type: 'date' },
statusCode: { type: 'int', optional: true },
statusMessage: { type: 'string', optional: true },
token: { type: 'string' },
realmUrl: { type: 'string', optional: true },
},
primaryKey: 'id'
id: { type: 'string', optional: false },
createdAt: {type: 'date', default: new Date()},
updatedAt: {type: 'date', default: new Date()},
statusCode: { type: 'int', optional: true },
statusMessage: {type: 'string', optional: true},
token: { type: 'string' },
realmUrl: { type: 'string', optional: true }
}
}
];

View File

@ -29,20 +29,17 @@ function generateUniqueId() {
return uuid;
}
const permissionSchema = [
{
const permissionSchema = [{
name: 'Permission',
properties: {
id: { type: 'string' },
updatedAt: { type: 'date' },
userId: { type: 'string' },
path: { type: 'string' },
mayRead: { type: 'bool' },
mayWrite: { type: 'bool' },
mayManage: { type: 'bool' },
userId: {type: 'string' },
path: { type: 'string' },
mayRead: { type: 'bool', optional: false },
mayWrite: { type: 'bool', optional: false },
mayManage: { type: 'bool', optional: false },
updatedAt: { type: 'date', optional: false },
}
}
];
}];
// Symbols are not supported on RN yet, so we use this for now:
const specialPurposeRealmsKey = '_specialPurposeRealms';
@ -81,7 +78,7 @@ function getSpecialPurposeRealm(user, realmName, schema) {
_Realm._waitForDownload(config, (error) => {
// FIXME: I don't understand why, but removing the following setTimeout causes the subsequent
// setTimeout call (when resolving the promise) to hang on RN iOS.
// setTimeout call (when resolving the promise) to hang on RN iOS.
// This might be related to our general makeCallback issue: #1255.
setTimeout(() => {}, 1);
@ -108,7 +105,7 @@ function createInManagementRealm(user, modelName, modelInitializer) {
return new Promise((resolve, reject) => {
try {
let o;
const listener = () => {
if (!o) {
return;
@ -156,7 +153,7 @@ module.exports = {
.then(permissionRealm => {
let permissions = permissionRealm.objects('Permission')
.filtered('NOT path ENDSWITH "__permission" AND NOT path ENDSWITH "__management"');
if (recipient === 'currentUser') {
permissions = permissions.filtered('userId = $0', this.identity);
}
@ -234,7 +231,7 @@ module.exports = {
if (!token) {
return Promise.reject(new Error('Offer token must be specified'));
}
const permissionOfferResponse = {
id: generateUniqueId(),
createdAt: new Date(),
@ -255,7 +252,7 @@ module.exports = {
// We were given a token, not an object. Find the matching object.
const q = managementRealm.objects('PermissionOffer')
.filtered('token = $0', permissionOfferOrToken);
if (q.length === 0) {
throw new Error("No permission offers with the given token were found");
}