Skip to content

Commit

Permalink
fix: stop double substituting unauthorized error (#1191)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrussell authored and djanicekpach committed Feb 29, 2024
1 parent 7e98aab commit 571b5e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 11 additions & 1 deletion master/internal/api_notebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/determined-ai/determined/master/pkg/tasks"
"github.com/determined-ai/determined/proto/pkg/apiv1"
"github.com/determined-ai/determined/proto/pkg/notebookv1"
"github.com/determined-ai/determined/proto/pkg/rbacv1"
"github.com/determined-ai/determined/proto/pkg/workspacev1"
)

Expand Down Expand Up @@ -211,7 +212,16 @@ func (a *apiServer) isNTSCPermittedToLaunch(
if err := command.AuthZProvider.Get().CanGetTensorboard(
ctx, *user, workspaceID, spec.Metadata.ExperimentIDs, spec.Metadata.TrialIDs,
); err != nil {
return authz.SubIfUnauthorized(err, apiutils.MapAndFilterErrors(err, nil, nil))
var pdErr authz.PermissionDeniedError
if errors.As(err, &pdErr) {
for _, perm := range pdErr.RequiredPermissions {
if perm == rbacv1.PermissionType_PERMISSION_TYPE_VIEW_WORKSPACE {
return apiutils.ErrNotFound
}
}
}

return apiutils.MapAndFilterErrors(err, nil, nil)
}
} else {
if err := command.AuthZProvider.Get().CanCreateNSC(
Expand Down
6 changes: 1 addition & 5 deletions master/internal/command/authz_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"context"
"fmt"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

log "github.com/sirupsen/logrus"

"github.com/determined-ai/determined/master/internal/authz"
Expand Down Expand Up @@ -191,8 +188,7 @@ func (a *NSCAuthZRBAC) CanGetTensorboard(
err := a.checkForPermission(ctx, curUser, workspaceID,
rbacv1.PermissionType_PERMISSION_TYPE_VIEW_WORKSPACE)
if err != nil {
return authz.SubIfUnauthorized(err,
status.Errorf(codes.NotFound, "workspace (%d) not found", workspaceID))
return err
}

expToWorkspaceIDs, err := db.ExperimentIDsToWorkspaceIDs(ctx, experimentIDs)
Expand Down

0 comments on commit 571b5e6

Please sign in to comment.