From 30c80b09238d830b233568240de7a56e2fc6b65d Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Fri, 22 Jan 2021 14:11:13 +0100 Subject: [PATCH 1/2] Check if roles are present in user object before looking those up --- changelog/unreleased/account-roles-fix.md | 3 +++ ocis-pkg/middleware/account.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/account-roles-fix.md diff --git a/changelog/unreleased/account-roles-fix.md b/changelog/unreleased/account-roles-fix.md new file mode 100644 index 0000000000..35dce3a1bd --- /dev/null +++ b/changelog/unreleased/account-roles-fix.md @@ -0,0 +1,3 @@ +Bugfix: Check if roles are present in user object before looking those up + +https://github.com/owncloud/ocis/pull/1388 diff --git a/ocis-pkg/middleware/account.go b/ocis-pkg/middleware/account.go index c02ca9f30a..1e9b70c2de 100644 --- a/ocis-pkg/middleware/account.go +++ b/ocis-pkg/middleware/account.go @@ -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)) }) } From 414b635433614f9e602dfba84c77453d216ef629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 29 Jan 2021 09:46:37 +0000 Subject: [PATCH 2/2] Automated changelog update [skip ci] --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3f3fba03..006278cffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,16 @@ The following sections list the changes for unreleased. ## Summary +* Bugfix - Check if roles are present in user object before looking those up: [#1388](https://github.com/owncloud/ocis/pull/1388) * Change - Move runtime code on refs/pman over to owncloud/ocis/ocis: [#1483](https://github.com/owncloud/ocis/pull/1483) * Enhancement - Update reva to v1.5.2-0.20210125114636-0c10b333ee69: [#1482](https://github.com/owncloud/ocis/pull/1482) ## Details +* Bugfix - Check if roles are present in user object before looking those up: [#1388](https://github.com/owncloud/ocis/pull/1388) + + https://github.com/owncloud/ocis/pull/1388 + * Change - Move runtime code on refs/pman over to owncloud/ocis/ocis: [#1483](https://github.com/owncloud/ocis/pull/1483) Tags: ocis, runtime