minio / mc

Unix like utilities for object store
https://min.io/download
GNU Affero General Public License v3.0
2.88k stars 552 forks source link

Add `mc admin accesskey` commands #5038

Closed taran-p closed 1 month ago

taran-p commented 2 months ago

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 license. By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 license.

Description

Adds mc admin accesskey commands that are equivalent to mc idp ldap accesskey commands, but for builtin users.

mc idp ldap accesskey create-with-login is not brought over as it is unnecessary for builtin users.

Motivation and Context

mc idp ldap accesskey commands currently have no builtin equivalents.

How to test this PR?

Use commands on builtin users. For mc admin accesskey list, minio/minio#20381 is necessary.

Types of changes

Checklist:

zveinn commented 1 month ago

@taran-p can you resolve the conflicts ? and when you're done.. please tag someone again to take a look

shtripat commented 1 month ago

Testing with latest MinIO master and seeing below

$ mc  mc admin accesskey create m1 --access-key user1 --secret-key user1234                                   
Access Key: user1                                                                                                                                 
Secret Key: user1234                                                                                                                              
Expiration: NONE                                                                                                                                  
Name:                                                                                                                                             
Description:                                                                                                                                      

$ mc  mc admin accesskey ls m1                                                                                
$ mc admin accesskey info    m1 user1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xfe275c]

goroutine 1 [running]:
github.com/minio/mc/cmd.nilExpiry(...)
        github.com/minio/mc/cmd/idp-ldap-accesskey-info.go:184
github.com/minio/mc/cmd.commonAccesskeyInfo(0x6883b9?)
        github.com/minio/mc/cmd/idp-ldap-accesskey-info.go:174 +0x4dc
github.com/minio/mc/cmd.mainAdminAccesskeyInfo(0xc00071d801?)
        github.com/minio/mc/cmd/admin-accesskey-info.go:49 +0x13
github.com/minio/cli.HandleAction({0x115f840?, 0x13fdf28?}, 0x4?)
        github.com/minio/cli@v1.24.2/app.go:490 +0x50
github.com/minio/cli.Command.Run({{0x133e545, 0x4}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x13716fa, 0x21}, {0x0, ...}, ...}, ...)
        github.com/minio/cli@v1.24.2/command.go:242 +0x935
github.com/minio/cli.(*App).RunAsSubcommand(0xc0005056c0, 0xc0005b0d00)
        github.com/minio/cli@v1.24.2/app.go:380 +0xc5b
github.com/minio/cli.Command.startApp({{0x1345787, 0x9}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1388bd4, 0x2e}, {0x0, ...}, ...}, ...)
        github.com/minio/cli@v1.24.2/command.go:346 +0xaf8
github.com/minio/cli.Command.Run({{0x1345787, 0x9}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1388bd4, 0x2e}, {0x0, ...}, ...}, ...)
        github.com/minio/cli@v1.24.2/command.go:117 +0x418
github.com/minio/cli.(*App).RunAsSubcommand(0xc000487dc0, 0xc0006296c0)
        github.com/minio/cli@v1.24.2/app.go:380 +0xc5b
github.com/minio/cli.Command.startApp({{0x133f4df, 0x5}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1355e26, 0x14}, {0x0, ...}, ...}, ...)
        github.com/minio/cli@v1.24.2/command.go:346 +0xaf8
github.com/minio/cli.Command.Run({{0x133f4df, 0x5}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1355e26, 0x14}, {0x0, ...}, ...}, ...)
        github.com/minio/cli@v1.24.2/command.go:117 +0x418
github.com/minio/cli.(*App).Run(0xc000505180, {0xc00003e1e0, 0x6, 0x6})
        github.com/minio/cli@v1.24.2/app.go:260 +0xa7b
github.com/minio/mc/cmd.Main({0xc00003e1e0, 0x6, 0x6})
        github.com/minio/mc/cmd/main.go:142 +0x445
main.main()
        github.com/minio/mc/main.go:28 +0x2c

Just created user not getting listed and info command panics. Please check.

taran-p commented 1 month ago

@shtripat accesskey info issue fixed. Not listing root access keys is a server side issue.