You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Declare all permission names as constants in pkg/permission #1032
The names of the permissions that reva checks (Drives.List, Drives.ReadWrite, ...) are partly constants and partly string literals. A typo in a literal compiles fine and silently denies the permission at runtime. Declaring every name once as a constant in pkg/permission and using only those would let the compiler catch it, and would let opencloud use the same constants when it defines the permissions.
Current state
pkg/permission/permission.go declares constants for some names: ListAllSpaces (Drives.List), CreateSpace (Drives.Create), WritePublicLink, WriteShare, GuestMailWrite, ListFavorites, WriteFavorites, DeleteReadOnlyPassword. The share providers and the OCS sharing handlers use them.
pkg/storage/pkg/decomposedfs/permissions/spacepermissions.go checks all space permissions with literals: Drives.Create, Drives.ReadWritePersonalQuota, Drives.ReadWriteProjectQuota, Drives.ReadWrite, Drives.ReadWriteEnabled, Drives.List, Drives.DeleteProject, Drives.DeletePersonal. Two of them (Drives.List, Drives.Create) already have constants that it doesn't use.
Add a constant to pkg/permission for every permission name reva checks, with a doc comment saying what it allows.
Replace the literals in spacepermissions.go (and anywhere else) with these constants.
No behaviour change: the values stay the same.
opencloud defines the permissions in services/settings/pkg/store/defaults/permissions.go with the same names as literals. Once the constants exist here, opencloud can use them from its vendored reva: see opencloud-eu/opencloud#4053.
Activity