fix: don't allow creating an auth with instance resources (#442)

* fix: don't allow creating an auth with instance resources

* fix: handle operator flag as well
This commit is contained in:
Jeffrey Smith II 2022-08-29 14:01:05 -04:00 committed by GitHub
parent 5c7c34f16d
commit 3a593e7184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -169,6 +169,11 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
return err
}
for _, r := range resources {
if r == string(extras.RESOURCEENUMOSS_INSTANCE) {
// We skip the instance type since it is only set on setup
continue
}
for _, action := range []string{ReadAction, WriteAction} {
permissions = append(permissions, api.Permission{
Action: action,
@ -207,6 +212,9 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
},
})
}
} else if r == string(extras.RESOURCEENUMOSS_INSTANCE) {
// We skip the instance type since it is only set on setup
continue
} else {
for _, action := range []string{ReadAction, WriteAction} {
permissions = append(permissions, api.Permission{

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/influxdata/influx-cli/v2/api/extras"
"github.com/influxdata/influx-cli/v2/clients/auth"
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
"github.com/urfave/cli"
@ -91,6 +92,10 @@ func newCreateCommand() cli.Command {
params.ResourcePermissions = auth.BuildResourcePermissions()
for _, perm := range params.ResourcePermissions {
if perm.Name == string(extras.RESOURCEENUMOSS_INSTANCE) {
// Instance permissions are only set during setup
continue
}
help := helpText(perm.Name)
ossVsCloud := ""
if perm.IsCloud && !perm.IsOss {