Add metadata to groups

Hi, still implementing scim api in an app.

In the protocol, on resource creation (user or group), the Id provider will give an ExternalId property, that allows it, on the next list to be able to easily map resources (users or groups) between updates.

On the user side of the story, this will be easy, I’ll use oc_preferences to store/show this external_id.

On the groups, there is currently no way, not that I’m aware, to store metadata on this object.

I though about various workarounds to avoid creating a table for my app:

  • preferences, but it has to belong to a user
  • comments, it could be a comment about the group, but I don’t think this should be used for that
  • systemtag, this is not a tag, this is a key=value thing
  • appconfig, maybe it could be an app config
nextcloud=# select * from oc_appconfig;
appid configkey configvalue
scim admin_externalid 1234
scim group1_externalid 5678

Maybe this is the easiest, but this is not really an app config, but more metadata about groups.

Then, maybe, the best option would be to have an app that allows any dev to add metadata about any objects in the DB? Something like:

nextcloud=# select * from oc_metadata;
object_type object_id key value
group admin externalid 1234
group group1 externalid 5678
file 1234 foo bar
user admin test value

And this app woul dbe a dependence to my app? Does it exist to have dependencies between apps?

And finally, I could also just create and maintain my own table… But I have the feeling that this is not the best option :slight_smile:

Curious about your opinions!

Thanks and have a nice day!

I don’t know what’s considered best practices in Nextcloud.
Although a generic table is easy for developers, I think it’s better to use a dedicated table as we can rely on the database relational engine to provide strong consistency. Foreign key and cascade delete could be really useful for this case.

1 Like

Ok, so you mean having our own table, something like:

nextcloud=# select * from oc_groups_scimserviceprovider;
gid external_id
admin 1234
group1 5678

Implemented in such a way that if we delete the app, the table is deleted.
And if we delete a group, the corresponding line in the group_scim table is also deleted, correct @hougo ?

Yeah. Maybe the other way around: if you delete a group, it deletes the corresponding line in group_scim.