Setting permissions to a realm directly in Realm Studio


#1

According to the docs as listed here, you can add permissions to a new realm via Realm Studio without any programming:

Realm Studio is a powerful tool, and one of the advanced features it provides is the ability to create a Realm and assign permissions to it, without needing to do this programmatically.

However, in the proceeding steps, particularly step 3:

1. Open the special ___admin_ Realm from Realm Studio, then select Permission.

I cannot find the __admin realm, so I can’t set permissions.

Is this no longer an option in Realm Studio and the documents simply don’t reflect that?
(FWIW, I am using Realm Studio version 1.19.0)

Many thanks.


#2

There is currently no way to set it in Realm Studio. I asked the question indirectly in something else: Setting User Permissions in Realm Cloud

If you’re using 2.x of ROS (which is what I believe all Realm Cloud accounts have currently unless you specifically requested an upgrade) you can set the permissions with a script like the following (this is in Node.js):

const Realm = require('realm');

const username = '[ADMIN-USER]';
const password = '[PASSWORD]';
const URL = '[SERVER]';
const realm = '[REALM]';

Realm.Sync.User.login(`https://${URL}`, username, password).then(user => {

  return user.applyPermissions({userId: '*'}, `realms://${URL}/${realm}`, 'write');

}).then(rslt => {
  console.log('Got the result of', rslt);
}).catch(err => {
  console.log('Problem trying to set permissions', err);
});

It will return back if it had a problem otherwise it should return back the results of the permissions being set.

The key line is the .applyPermissions() which in this case will set the realm to be writeable by all logged in users. You can change it to specific users or to just have ‘read’ access, just add multiple applyPermissions().

Once it is successful you’ll see the permissions indicated in Realm Studio.

I’ve got a support ticket open currently waiting to hear back how to do this in 3.0, this code currently doesn’t work for it and the docs for 3.0 don’t give an alternative.


#3

The __admin Realm has been made hidden by default in new Studio releases as we consider directly manipulating it an advanced scenario and we didn’t want a confusing first experience for new users. You can turn on showing it in the list of Realms by going to the View menu and enabling the Show system Realms option. We’ll update the docs to point that out as it’s clearly not obvious.


#4

Ah, I understand now.

Thanks @tomjnsn for your code suggestion. I did locate your post about permissions when I searched the forums and tried to see if I could spot the answer I needed there.

Thanks to @nirinchev too for the update on why it was hidden. I have activated system Realms and can now see __admin. Greatly appreciate the consideration to update the docs.