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:
parent
5c7c34f16d
commit
3a593e7184
@ -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{
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user