Repository navigation
Open
Labels
Type:MaintenanceE.g. technical debt, packaging, etc.
Description
The default permissions in services/settings/pkg/store/defaults/permissions.go have their UUIDs and names as string literals. Three of the UUIDs are written a second time as constants elsewhere, and the names are repeated as literals in other services and in reva. Nothing links these copies: if one changes, or has a typo, it still compiles, and the permission check silently fails at runtime.
Current state
- UUIDs: each permission in
permissions.gohas its UUID inline.services/settings/pkg/service/v0/settings.godeclaresAccountManagementPermissionID,RoleManagementPermissionIDandSettingsManagementPermissionIDwith the same values, butpermissions.godoesn't use them. These three are looked up by ID in auth-app, in the graphrequireadminmiddleware and in the settings service itself. - Precedent:
defaults/defaults.goalready declares the role and setting UUIDs as constants (BundleUUIDRoleAdmin,SettingUUIDProfileLanguage, ...). The permission UUIDs are the exception. - Names: everything else checks permissions by name. reva checks them in its storage drivers and share providers, and the web service here checks
Announcement.ReadWriteandLogo.Writeas literals.permissions.godefines the names as literals too.
Proposal
- Declare the permission UUIDs as constants in
services/settings/pkg/store/defaults, next to the existingBundleUUID...andSettingUUID...constants, and use them inpermissions.go. - Make the three constants in
services/settings/pkg/service/v0/settings.gorefer to them (or replace their uses), so each UUID is written once. - Use the permission name constants from reva's
pkg/permissioninpermissions.goand in the web service, once reva declares all of them (see Declare all permission names as constants inpkg/permissionreva#1032). Names that only opencloud checks, likeLogo.Write, get constants here.
No behaviour change: the values stay the same. The example JSON in services/settings/README.md repeats the UUIDs too; it's documentation and can stay as it is.
Metadata
Metadata
Assignees
Labels
Type:MaintenanceE.g. technical debt, packaging, etc.
Activity