Skip to content

Commit

Permalink
Merge pull request #1388 from ishank011/roles-fix
Browse files Browse the repository at this point in the history
Check if roles are present in user object before looking those up
  • Loading branch information
butonic authored Jan 29, 2021
2 parents 4fa7366 + 30c80b0 commit 1b9126a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/unreleased/account-roles-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Check if roles are present in user object before looking those up

https://github.com/owncloud/ocis/pull/1388
6 changes: 5 additions & 1 deletion ocis-pkg/middleware/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}
Expand Down

0 comments on commit 1b9126a

Please sign in to comment.