Add name and description for service accounts (#4569)
This commit is contained in:
@@ -50,8 +50,17 @@ var adminUserSvcAcctAddFlags = []cli.Flag{
|
||||
Usage: "path to a JSON policy file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "comment",
|
||||
Usage: "personal note for the service account",
|
||||
Name: "name",
|
||||
Usage: "friendly name for the service account",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "description",
|
||||
Usage: "description for the service account",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "comment",
|
||||
Hidden: true,
|
||||
Usage: "description for the service account (DEPRECATED: use --description instead)",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -69,14 +78,14 @@ USAGE:
|
||||
{{.HelpName}} ALIAS ACCOUNT
|
||||
|
||||
ACCOUNT:
|
||||
An account could be a regular MinIO user, STS ou LDAP user.
|
||||
An account could be a regular MinIO user, STS or LDAP user.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Add a new service account for user 'foobar' to MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} myminio foobar
|
||||
1. Add a new service account for user 'foobar' to MinIO server with a name and description.
|
||||
{{.Prompt}} {{.HelpName}} myminio foobar --name uploaderKey --description "foobar uploader scripts"
|
||||
2. Add a new service account to MinIO server with specified access key and secret key for user'foobar'.
|
||||
{{.Prompt}} {{.HelpName}} myminio foobar --access-key "myaccesskey" --secret-key "mysecretkey"
|
||||
3. Add a new service account to MinIO server with specified access key and random secret key for user'foobar'.
|
||||
@@ -102,7 +111,8 @@ type acctMessage struct {
|
||||
ParentUser string `json:"parentUser,omitempty"`
|
||||
ImpliedPolicy bool `json:"impliedPolicy,omitempty"`
|
||||
Policy json.RawMessage `json:"policy,omitempty"`
|
||||
Comment string `json:"comment,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
AccountStatus string `json:"accountStatus,omitempty"`
|
||||
MemberOf []string `json:"memberOf,omitempty"`
|
||||
Expiration *time.Time `json:"expiration,omitempty"`
|
||||
@@ -160,7 +170,8 @@ func (u acctMessage) String() string {
|
||||
fmt.Sprintf("AccessKey: %s", u.AccessKey),
|
||||
fmt.Sprintf("ParentUser: %s", u.ParentUser),
|
||||
fmt.Sprintf("Status: %s", u.AccountStatus),
|
||||
fmt.Sprintf("Comment: %s", u.Comment),
|
||||
fmt.Sprintf("Name: %s", u.Name),
|
||||
fmt.Sprintf("Description: %s", u.Description),
|
||||
fmt.Sprintf("Policy: %s", policyField),
|
||||
func() string {
|
||||
if u.Expiration != nil {
|
||||
@@ -242,7 +253,11 @@ func mainAdminUserSvcAcctAdd(ctx *cli.Context) error {
|
||||
accessKey := ctx.String("access-key")
|
||||
secretKey := ctx.String("secret-key")
|
||||
policyPath := ctx.String("policy")
|
||||
comment := ctx.String("comment")
|
||||
name := ctx.String("name")
|
||||
description := ctx.String("description")
|
||||
if description == "" {
|
||||
description = ctx.String("comment")
|
||||
}
|
||||
|
||||
// generate access key and secret key
|
||||
if len(accessKey) <= 0 || len(secretKey) <= 0 {
|
||||
@@ -276,11 +291,12 @@ func mainAdminUserSvcAcctAdd(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
opts := madmin.AddServiceAccountReq{
|
||||
Policy: policyBytes,
|
||||
AccessKey: accessKey,
|
||||
SecretKey: secretKey,
|
||||
Comment: comment,
|
||||
TargetUser: user,
|
||||
Policy: policyBytes,
|
||||
AccessKey: accessKey,
|
||||
SecretKey: secretKey,
|
||||
Name: name,
|
||||
Description: description,
|
||||
TargetUser: user,
|
||||
}
|
||||
|
||||
creds, e := client.AddServiceAccount(globalContext, opts)
|
||||
|
||||
@@ -98,7 +98,8 @@ func mainAdminUserSvcAcctInfo(ctx *cli.Context) error {
|
||||
printMsg(acctMessage{
|
||||
op: svcAccOpInfo,
|
||||
AccessKey: svcAccount,
|
||||
Comment: svcInfo.Comment,
|
||||
Name: svcInfo.Name,
|
||||
Description: svcInfo.Description,
|
||||
AccountStatus: svcInfo.AccountStatus,
|
||||
ParentUser: svcInfo.ParentUser,
|
||||
ImpliedPolicy: svcInfo.ImpliedPolicy,
|
||||
|
||||
@@ -35,8 +35,12 @@ var adminUserSvcAcctSetFlags = []cli.Flag{
|
||||
Usage: "path to a JSON policy file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "comment",
|
||||
Usage: "personal note for the service account",
|
||||
Name: "name",
|
||||
Usage: "name for the service account",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "description",
|
||||
Usage: "description for the service account",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -81,7 +85,8 @@ func mainAdminUserSvcAcctSet(ctx *cli.Context) error {
|
||||
|
||||
secretKey := ctx.String("secret-key")
|
||||
policyPath := ctx.String("policy")
|
||||
comment := ctx.String("comment")
|
||||
name := ctx.String("name")
|
||||
description := ctx.String("description")
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
@@ -95,9 +100,10 @@ func mainAdminUserSvcAcctSet(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
opts := madmin.UpdateServiceAccountReq{
|
||||
NewPolicy: buf,
|
||||
NewSecretKey: secretKey,
|
||||
NewComment: comment,
|
||||
NewPolicy: buf,
|
||||
NewSecretKey: secretKey,
|
||||
NewName: name,
|
||||
NewDescription: description,
|
||||
}
|
||||
|
||||
e := client.UpdateServiceAccount(globalContext, svcAccount, opts)
|
||||
|
||||
@@ -19,7 +19,7 @@ require (
|
||||
github.com/minio/cli v1.24.2
|
||||
github.com/minio/colorjson v1.0.4
|
||||
github.com/minio/filepath v1.0.0
|
||||
github.com/minio/madmin-go/v2 v2.1.1
|
||||
github.com/minio/madmin-go/v2 v2.1.3
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/minio-go/v7 v7.0.52
|
||||
github.com/minio/pkg v1.6.5
|
||||
|
||||
@@ -518,8 +518,8 @@ github.com/minio/colorjson v1.0.4/go.mod h1:ZgE8vYon4xC4yfBPclP/2gqMRYw+p+xRsBbL
|
||||
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
|
||||
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
|
||||
github.com/minio/madmin-go v1.6.6/go.mod h1:ATvkBOLiP3av4D++2v1UEHC/QzsGtgXD5kYvvRYzdKs=
|
||||
github.com/minio/madmin-go/v2 v2.1.1 h1:qUdJP31MD3ThPOmvfRby0J5ZJdAw5XK67LxTkUI9DWA=
|
||||
github.com/minio/madmin-go/v2 v2.1.1/go.mod h1:8bL1RMNkblIENFSgGYjeHrzUx9PxROb7OqfNuMU9ivE=
|
||||
github.com/minio/madmin-go/v2 v2.1.3 h1:9pkUgAujfm/SaFei4a1LwpS2et1/qGvRjFqFbRWa6xA=
|
||||
github.com/minio/madmin-go/v2 v2.1.3/go.mod h1:8bL1RMNkblIENFSgGYjeHrzUx9PxROb7OqfNuMU9ivE=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.41/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw=
|
||||
|
||||
Reference in New Issue
Block a user