Skip to content

Commit

Permalink
allow scope check to impersonate space owners (cs3org#3843)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored and 2403905 committed May 19, 2023
1 parent 9b136a2 commit ba4eedd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: allow scope check to impersonate space owners

The publicshare scope check now fakes a user to mint an access token when impersonating a user of type `SPACE_OWNER` which is used for project spaces. This fixes downloading archives from public link shares in project spaces.

https://github.com/cs3org/reva/pull/3843
https://github.com/owncloud/ocis/issues/5229
17 changes: 13 additions & 4 deletions internal/grpc/interceptors/auth/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,25 @@ func checkIfNestedResource(ctx context.Context, ref *provider.Reference, parent
// We mint a token as the owner of the public share and try to stat the reference
// TODO(ishank011): We need to find a better alternative to this

userResp, err := client.GetUser(ctx, &userpb.GetUserRequest{UserId: statResponse.Info.Owner, SkipFetchingUserGroups: true})
if err != nil || userResp.Status.Code != rpc.Code_CODE_OK {
return false, err
var user *userpb.User
if statResponse.GetInfo().GetOwner().GetType() == userpb.UserType_USER_TYPE_SPACE_OWNER {
// fake a space owner user
user = &userpb.User{
Id: statResponse.GetInfo().GetOwner(),
}
} else {
userResp, err := client.GetUser(ctx, &userpb.GetUserRequest{UserId: statResponse.Info.Owner, SkipFetchingUserGroups: true})
if err != nil || userResp.Status.Code != rpc.Code_CODE_OK {
return false, err
}
user = userResp.User
}

scope, err := scope.AddOwnerScope(map[string]*authpb.Scope{})
if err != nil {
return false, err
}
token, err := mgr.MintToken(ctx, userResp.User, scope)
token, err := mgr.MintToken(ctx, user, scope)
if err != nil {
return false, err
}
Expand Down

0 comments on commit ba4eedd

Please sign in to comment.