diff --git a/internal/auth/jwtauth.go b/internal/auth/jwtauth.go index 3c14057946..0557e65803 100644 --- a/internal/auth/jwtauth.go +++ b/internal/auth/jwtauth.go @@ -27,7 +27,6 @@ import ( "github.com/lestrrat-go/jwx/v2/jwt/openid" "github.com/spf13/cobra" "github.com/spf13/viper" - "golang.org/x/exp/slices" "github.com/stacklok/minder/internal/constants" "github.com/stacklok/minder/internal/util" @@ -152,19 +151,6 @@ func GetDefaultProject(ctx context.Context) (uuid.UUID, error) { return permissions.ProjectIds[0], nil } -// IsAuthorizedForProject returns true if the user is authorized for the given project -func IsAuthorizedForProject(ctx context.Context, projectID uuid.UUID) bool { - permissions := GetPermissionsFromContext(ctx) - - return slices.Contains(permissions.ProjectIds, projectID) -} - -// GetUserProjects returns all the projects where a user belongs to -func GetUserProjects(ctx context.Context) ([]uuid.UUID, error) { - permissions := GetPermissionsFromContext(ctx) - return permissions.ProjectIds, nil -} - // UserDetails is a helper struct for getting user details type UserDetails struct { Name string diff --git a/internal/controlplane/handlers_profile.go b/internal/controlplane/handlers_profile.go index e3b4f16887..99e1607ca8 100644 --- a/internal/controlplane/handlers_profile.go +++ b/internal/controlplane/handlers_profile.go @@ -93,7 +93,7 @@ func (s *Server) ensureDefaultProjectForContext(ctx context.Context, inout *mind // verifyValidProject verifies that the project is valid and the user is authorized to access it // TODO: This will have to change once we have the hierarchy tree in place. func verifyValidProject(ctx context.Context, in *engine.EntityContext) error { - if !auth.IsAuthorizedForProject(ctx, in.GetProject().GetID()) { + if err := AuthorizedOnProject(ctx, in.GetProject().GetID()); err != nil { return status.Errorf(codes.PermissionDenied, "user is not authorized to access this resource") }