Skip to content

Commit

Permalink
check service user in decomposedfs
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Aug 11, 2023
1 parent 7b6d8fa commit ff46118
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,10 @@ func (n *Node) ReadUserPermissions(ctx context.Context, u *userpb.User) (ap prov
return OwnerPermissions(), false, nil
}

if u.Id.GetOpaqueId() == "service-user-id" {
return OwnerPermissions(), false, nil
}

ap = provider.ResourcePermissions{}

// for an efficient group lookup convert the list of groups to a map
Expand Down
7 changes: 4 additions & 3 deletions pkg/utils/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func GetUser(userID *user.UserId, gwc gateway.GatewayAPIClient, machineAuthAPIKe
}

// ImpersonateUser impersonates the given user
// NOTE: this will go away soon, try to use ImpersonateServiceUser
func ImpersonateUser(usr *user.User, gwc gateway.GatewayAPIClient, machineAuthAPIKey string) (context.Context, error) {
if true {
return ImpersonateServiceUser("service-user-id", gwc, "secret-string")
Expand All @@ -57,12 +58,12 @@ func ImpersonateUser(usr *user.User, gwc gateway.GatewayAPIClient, machineAuthAP
}

// ImpersonateServiceUser impersonates the given user
func ImpersonateServiceUser(userID string, gwc gateway.GatewayAPIClient, machineAuthAPIKey string) (context.Context, error) {
func ImpersonateServiceUser(serviceUserID string, gwc gateway.GatewayAPIClient, serviceUserSecret string) (context.Context, error) {
ctx := context.Background()
authRes, err := gwc.Authenticate(ctx, &gateway.AuthenticateRequest{
Type: "serviceaccounts",
ClientId: userID,
ClientSecret: machineAuthAPIKey,
ClientId: serviceUserID,
ClientSecret: serviceUserSecret,
})
if err != nil {
return nil, err
Expand Down

0 comments on commit ff46118

Please sign in to comment.