cobbler / cli

Independent CLI written in Go for the Cobbler server.
GNU General Public License v2.0
1 stars 4 forks source link

Fix login requests #42

Closed nodeg closed 5 months ago

nodeg commented 3 years ago

At the moment we have a login request when executing e.g. cobbler completion * which is not intended. We should implement a kind of blacklist where commands are listed that do not require logins.

Examples:

$ make build
building package
go build -o cobbler main.go
creating shell completions
make shell_completions
make[1]: Entering directory '/home/dom/git/cobblercli'
./cobbler completion bash > config/completions/bash/cobbler
Using config file: /home/dom/.cobbler.yaml
error! Failed to login: Post "http://127.0.0.1/cobbler_api": dial tcp 127.0.0.1:80: connect: connection refused
./cobbler completion fish > config/completions/fish/cobbler
Using config file: /home/dom/.cobbler.yaml
error! Failed to login: Post "http://127.0.0.1/cobbler_api": dial tcp 127.0.0.1:80: connect: connection refused
./cobbler completion powershell > config/completions/powershell/cobbler
Using config file: /home/dom/.cobbler.yaml
error! Failed to login: Post "http://127.0.0.1/cobbler_api": dial tcp 127.0.0.1:80: connect: connection refused
./cobbler completion zsh > config/completions/zsh/cobbler
Using config file: /home/dom/.cobbler.yaml
error! Failed to login: Post "http://127.0.0.1/cobbler_api": dial tcp 127.0.0.1:80: connect: connection refused
make[1]: Leaving directory '/home/dom/git/cobblercli'
$ ./cobbler completion zsh | less > cobbler.zsh
Using config file: /home/dom/.cobbler.yaml
error! Failed to login: Post "http://127.0.0.1/cobbler_api": dial tcp 127.0.0.1:80: connect: connection refused

Those messages are from stderr.

The login is handled here: https://github.com/cobbler/cli/blob/b82d106bf18bb3f3b874214bece5ea2569b87d17/cmd/root.go#L82-L96

and executed in initconfig().

SchoolGuy commented 3 years ago

As an alternative a whitelist could also be an option.

SchoolGuy commented 5 months ago

To implement the whitelist method I will move the client generation method call directly into each single CLI command.