Check if roles are present in user object before looking those up

This commit is contained in:
Ishank Arora
2021-01-22 14:11:13 +01:00
committed by Ingmar
parent fb2fe1dd19
commit 823e99efa9
2 changed files with 8 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
Bugfix: Check if roles are present in user object before looking those up
https://github.com/owncloud/ocis/pull/1388

View File

@@ -67,7 +67,11 @@ func ExtractAccountUUID(opts ...account.Option) func(http.Handler) http.Handler
ctx = context.WithValue(ctx, UUIDKey, u.Id.OpaqueId)
// TODO: implement token manager in cs3org/reva that uses generic metadata instead of access token from header.
ctx = metadata.Set(ctx, AccountID, u.Id.OpaqueId)
ctx = metadata.Set(ctx, RoleIDs, string(u.Opaque.Map["roles"].Value))
if u.Opaque != nil {
if roles, ok := u.Opaque.Map["roles"]; ok {
ctx = metadata.Set(ctx, RoleIDs, string(roles.Value))
}
}
next.ServeHTTP(w, r.WithContext(ctx))
})
}