From a91664fdd0b154f894261be372f930dc10916fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 22 Oct 2020 15:16:26 +0200 Subject: [PATCH] Mint token with uid and gid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- accounts/pkg/storage/cs3.go | 16 +++++++++++++++- changelog/unreleased/mint-token-with-uid.md | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/mint-token-with-uid.md diff --git a/accounts/pkg/storage/cs3.go b/accounts/pkg/storage/cs3.go index 930144c875..81d30203a0 100644 --- a/accounts/pkg/storage/cs3.go +++ b/accounts/pkg/storage/cs3.go @@ -8,11 +8,13 @@ import ( "io/ioutil" "net/http" "path" + "strconv" "strings" user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" v1beta11 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/cs3org/reva/pkg/rgrpc/todo/pool" "github.com/cs3org/reva/pkg/token" "github.com/cs3org/reva/pkg/token/manager/jwt" @@ -95,7 +97,7 @@ func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *proto.Account) ( return err } - if resp.StatusCode == http.StatusNotFound { + if resp.StatusCode != http.StatusOK { return ¬FoundErr{"account", id} } @@ -222,6 +224,18 @@ func (r CS3Repo) authenticate(ctx context.Context) (token string, err error) { OpaqueId: r.cfg.ServiceUser.UUID, }, Groups: []string{}, + Opaque: &types.Opaque{ + Map: map[string]*types.OpaqueEntry{ + "uid": { + Decoder: "plain", + Value: []byte(strconv.FormatInt(r.cfg.ServiceUser.UID, 10)), + }, + "gid": { + Decoder: "plain", + Value: []byte(strconv.FormatInt(r.cfg.ServiceUser.GID, 10)), + }, + }, + }, } return r.tm.MintToken(ctx, u) } diff --git a/changelog/unreleased/mint-token-with-uid.md b/changelog/unreleased/mint-token-with-uid.md new file mode 100644 index 0000000000..94610cb224 --- /dev/null +++ b/changelog/unreleased/mint-token-with-uid.md @@ -0,0 +1,8 @@ +Bugfix: Mint token with uid and gid + +Tags: accounts + +The eos driver expects the uid and gid from the opaque map of a user. While the proxy does mint tokens correctly, the accounts service wasn't. + +https://github.com/owncloud/ocis/pull/737 +