Right way to create new user's Realms on Realm Object Server with permissions

451 Views Asked by At

I'm trying out the Realm Mobile Platform for determining if it will be suitable for a upcoming project.

I'm using the server admin user to login into my sample app, and by providing different paths in the SyncConfiguration object I'm able to create different Realms, locally and in the Object Server.

    String realmUrl = String.format("realm://%1$s:%2$s/my_realm_name", OBJECT_SERVER_IP, BASE_PORT);
    SyncConfiguration syncConfiguration = new SyncConfiguration.Builder(SyncUser.currentUser(), realmUrl).build();
    Realm realm = Realm.getInstance(syncConfiguration);

The problem is that when I access to the web dashboard, it seems that the administrator doesn't own the Realms he created with the client app.
So my question is: what's the best way for a user to create N owned Realms which may be shared to other users by managing access permissions?

1

There are 1 best solutions below

0
On

When Realm files are opened for the first time, the SDK will make a request for an access token to the authentication service of the Realm Object Server. This will look up whether a file at this path already exists and create it if not. Files created there will be only owned if they are in the current user's scope. The easiest way to achieve this would be if the users create the files on their own.

as user ID "userA":
  /~/my_realm_name     => /userA/my_realm_name => owned
  /userA/my_realm_name => /userA/my_realm_name => owned
  /userB/my_realm_name => fails (no permissions)
  /my_realm_name       => fails (no permissions)

as user ID "admin" with administrator privileges:
  /~/my_realm_name     => /admin/my_realm_name => owned
  /userA/my_realm_name => /userA/my_realm_name => unowned
  /userB/my_realm_name => /userA/my_realm_name => unowned
  /my_realm_name       => /my_realm_name       => unowned