Extensions: Permissions + explanations #166

Closed
opened 2024-06-04 11:58:35 +02:00 by Dalai Felinto · 8 comments

We want to support (require even) each required permission to be presented with the justification for that particular resource.

Excert from the proposed manifest schema:

   ## Optional: add-ons can list which resources they will require:
   ## * files (for access of any filesystem operations)
   ## * network (for internet access) - Remember to also check `bpy.app.online_access`
   ## * clipboard (to read and/or write the system clipboard)
   ## * camera (to capture photos and videos)
   ## * microphone (to capture audio)
   ##
   ## For each permission it is important to also specify the reason why it is required.
   ## Keep this a single short sentence without a period (.) at the end.
   ## For longer explanations use the documentation or detail page.
   #
   # [permissions]
   # network = "Need to sync motion-capture data to server"
   # files = "Import/export FBX from/to disk"
   # clipboard = "Copy and paste bone transforms"

While having permissions is optional, once you declare one its reasoning is also required.
The reason is a mandatory string, max length=64 (same as the extension tagline), without a period(.) at the end.

We want to support (require even) each required permission to be presented with the justification for that particular resource. Excert from the proposed manifest schema: ``` ## Optional: add-ons can list which resources they will require: ## * files (for access of any filesystem operations) ## * network (for internet access) - Remember to also check `bpy.app.online_access` ## * clipboard (to read and/or write the system clipboard) ## * camera (to capture photos and videos) ## * microphone (to capture audio) ## ## For each permission it is important to also specify the reason why it is required. ## Keep this a single short sentence without a period (.) at the end. ## For longer explanations use the documentation or detail page. # # [permissions] # network = "Need to sync motion-capture data to server" # files = "Import/export FBX from/to disk" # clipboard = "Copy and paste bone transforms" ``` While having permissions is optional, once you declare one its reasoning is also required. The reason is a mandatory string, max length=64 (same as the extension tagline), without a period(.) at the end.
Owner

Should the permission descriptions be shown anywhere on the website? This would require more changes to the model and design.

Should the permission descriptions be shown anywhere on the website? This would require more changes to the model and design.
Author
Owner

I would expect so, yes (otherwise it would be pointless to have them).

I would expect so, yes (otherwise it would be pointless to have them).
Owner

we should fix the example: file should be files

we should fix the example: `file` should be `files`
Owner

We should also settle on the vocabulary - it will be used in error messages and should be the same in the docs:
how do we call the string - is it reason or explanation or description?

I started using word "reason" in the validation code, but can change it if we want rephrase the docs.

We should also settle on the vocabulary - it will be used in error messages and should be the same in the docs: how do we call the string - is it reason or explanation or description? I started using word "reason" in the validation code, but can change it if we want rephrase the docs.
Owner

deployed #168

deployed #168
> we should fix the example: `file` should be `files` [Fixed](https://projects.blender.org/blender/blender-manual/commit/6c0a76526e69cde268bfd6b8f47a7f43fa538293). https://docs.blender.org/manual/en/dev/advanced/extensions/getting_started.html#manifest
Owner

Next steps:

  • update the metadata field for extensions that already have permissions defined in the old format, so we don't expect both cases in the code that looks it up
  • replace the Permission.help used in templates and API with the reason stored in Version.file.metadata (populated from manifest on version upload)

used this script to update metadata:

from extensions.models import Version, VersionPermission

permission_help = {p.slug: p.help for p in VersionPermission.objects.all()}
versions = Version.objects.select_related('file').all()

for version in versions:
    if 'permissions' in version.file.metadata and not isinstance(version.file.metadata['permissions'], dict):
        old = version.file.metadata['permissions']
        new = dict()
        for permission in old:
            new[permission] = permission_help[permission]
        version.file.metadata['permissions'] = new
        print(f"updating Version pk={version.pk} from {old} to {new}")
        version.file.save(update_fields={'metadata'})

Next steps: - [x] update the metadata field for extensions that already have permissions defined in the old format, so we don't expect both cases in the code that looks it up - [x] replace the Permission.help used in templates and API with the reason stored in Version.file.metadata (populated from manifest on version upload) used this script to update metadata: ``` from extensions.models import Version, VersionPermission permission_help = {p.slug: p.help for p in VersionPermission.objects.all()} versions = Version.objects.select_related('file').all() for version in versions: if 'permissions' in version.file.metadata and not isinstance(version.file.metadata['permissions'], dict): old = version.file.metadata['permissions'] new = dict() for permission in old: new[permission] = permission_help[permission] version.file.metadata['permissions'] = new print(f"updating Version pk={version.pk} from {old} to {new}") version.file.save(update_fields={'metadata'}) ```
Oleg-Komarov self-assigned this 2024-06-06 12:11:44 +02:00
Owner

All fixes deployed

All fixes deployed
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/extensions-website#166
No description provided.