@@ -158,27 +158,48 @@ func (csm claimSpaceManager) getSpaceAssignments(ctx context.Context) map[string
158
158
claims := oidc .FromContext (ctx )
159
159
values , ok := claims [csm .claimName ].([]any )
160
160
if ! ok {
161
- csm .logger .Error ().Interface ("entitlements " , claims [ "entitlements" ] ).Msg ("entitlements claims are not a []string " )
161
+ csm .logger .Error ().Interface ("claims " , claims ). Str ( "claimname" , csm . claimName ).Msg ("configured claims are not an array " )
162
162
}
163
163
164
164
assignments := make (map [string ]string )
165
165
for _ , ent := range values {
166
166
e , ok := ent .(string )
167
167
if ! ok {
168
- csm .logger .Error ().Interface ("entitlement " , ent ).Msg ("entitlement is not a sting " )
168
+ csm .logger .Error ().Interface ("assignment " , ent ).Msg ("assignment is not a string " )
169
169
continue
170
170
}
171
171
172
172
match , spaceid , role := csm .mapper .Exec (e )
173
173
if ! match {
174
174
continue
175
175
}
176
- assignments [spaceid ] = role
176
+ assignments [spaceid ] = chooseRole ( role , assignments [ spaceid ])
177
177
}
178
178
179
179
return assignments
180
180
}
181
181
182
+ // will return the role with the highest permissions.
183
+ func chooseRole (roleA , roleB string ) string {
184
+ if roleA == "" {
185
+ return roleB
186
+ }
187
+
188
+ if roleB == "" {
189
+ return roleA
190
+ }
191
+
192
+ permsA := conversions .RoleFromName (roleA ).CS3ResourcePermissions ()
193
+ permsB := conversions .RoleFromName (roleB ).CS3ResourcePermissions ()
194
+
195
+ if conversions .SufficientCS3Permissions (permsA , permsB ) {
196
+ return roleA
197
+ }
198
+ // Note: This could be an issue if roleB does not contain roleA
199
+ return roleB
200
+
201
+ }
202
+
182
203
func getSpaceMemberStatus (space * storageprovider.StorageSpace , userid string ) (bool , * storageprovider.ResourcePermissions , error ) {
183
204
var permissionsMap map [string ]* storageprovider.ResourcePermissions
184
205
if err := utils .ReadJSONFromOpaque (space .GetOpaque (), "grants" , & permissionsMap ); err != nil {
0 commit comments