Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error with jf config add --access-token and bad Access Token #1782

Open
Romain0424 opened this issue Dec 16, 2022 · 1 comment
Open

No error with jf config add --access-token and bad Access Token #1782

Romain0424 opened this issue Dec 16, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Romain0424
Copy link

Describe the bug

Compared with the basic auth method there is no check to validate the Access Token while executing the jf config add --access-token.

If a user enters a wrong token there is no message returned by the jf cli, it may confuse the user later while executing a command requiring authentication.

Current behavior


➜  eul-cli git:(main) ✗ jf config add --user pvmk05211 --access-token bad-token --url https://my-artifactory.url/ test

11:35:35 [Debug] JFrog CLI version: 2.29.2

11:35:35 [Debug] OS/Arch: linux/amd64

11:35:35 [Debug] Locking config file to run config AddOrEdit command.

11:35:35 [Debug] Creating lock in:  /home/pvmk05211/.jfrog/locks/config

Is the Artifactory reverse proxy configured to accept a client certificate? (y/n) [n]?

11:35:42 [Debug] Releasing lock:  /home/pvmk05211/.jfrog/locks/config/jfrog-cli.conf.lck.16826.1671186935792041800

11:35:42 [Debug] Config AddOrEdit command completed successfully. config file is released.

➜  eul-cli git:(main) ✗

➜  eul-cli git:(main) ✗

➜  eul-cli git:(main) ✗ jf rt go-config

11:35:52 [Debug] JFrog CLI version: 2.29.2

11:35:52 [Debug] OS/Arch: linux/amd64

11:35:52 [🟠Warn] You are using a deprecated syntax of the command.

        Instead of:

        $ jf rt go-config ...

        Use:

        $ jf go-config ...

Configuration file already exists at /home/pvmk05211/projects/eul-cli/.jfrog/projects/go.yaml. Override it? (y/n) [n]? y

Resolve dependencies from Artifactory? (y/n) [y]?

Set Artifactory server ID [prod]: test

11:36:03 [Debug] Sending HTTP GET request to: https://my-artifactory.url/artifactory/api/repositories?type=remote&packageType=

11:36:04 [🚨Error] failed getting repositories list: server response: 401 Unauthorized

{

  "errors": [

    {

      "status": 401,

      "message": "Bad credentials"

    }

  ]

}

Set repository for dependencies resolution (press Tab for options):

panic: Interrupted



goroutine 1 [running]:

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.askString.func1(0xc0004b0170?)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/questionnaire.go:84 +0x27

github.com/c-bata/go-prompt.(*Prompt).handleKeyBinding(0xc000296510, 0x3)

        /root/go/pkg/mod/github.com/c-bata/[email protected]/prompt.go:212 +0x10f

github.com/c-bata/go-prompt.(*Prompt).feed(0xc000296510, {0xc000276400, 0x1, 0x400})

        /root/go/pkg/mod/github.com/c-bata/[email protected]/prompt.go:160 +0x6bc

github.com/c-bata/go-prompt.(*Prompt).Input(0xc000296510)

        /root/go/pkg/mod/github.com/c-bata/[email protected]/prompt.go:251 +0x35a

github.com/c-bata/go-prompt.Input({0xc000120000, 0x44}, 0x0?, {0xc0004b0410, 0x1, 0xc0004b0448?})

        /root/go/pkg/mod/github.com/c-bata/[email protected]/shortcut.go:16 +0xc5

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.askString({0x0?, 0xc0003c20b0?}, {0xc00004a050, 0x43}, {0x0, 0x0}, 0x0, 0x4?)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/questionnaire.go:116 +0x2d1

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.AskString(...)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/questionnaire.go:100

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.readRepo({0xc00004a050, 0x43}, {0xc000124014?, 0xfc31aa?}, {0xc0004b0528?, 0xfe9aa8?, 0x19a3200?})

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/configfile.go:485 +0x148

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.(*ConfigFile).setRepo(...)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/configfile.go:385

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.(*ConfigFile).setResolver(0xc0002b4dc0)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/configfile.go:356 +0xe5

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.(*ConfigFile).setDeployerResolver(0xc0002b4dc0?)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/configfile.go:362 +0x1e

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.(*ConfigFile).configGo(...)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/configfile.go:226

github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils.CreateBuildConfig(0xc0002b4c60, 0x0)

        /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/utils/configfile.go:103 +0x1ba

github.com/jfrog/jfrog-cli/utils/cliutils.CreateConfigCmd(0xf91eee?, 0x9?)

        /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/utils/cliutils/utils.go:582 +0x37

github.com/jfrog/jfrog-cli/utils/cliutils.RunConfigCmdWithDeprecationWarning({0xf91eee?, 0x11a9d50?}, {0xf8014e?, 0x5?}, 0x0?, 0xc00031e6d8?, 0x1054378)

        /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/utils/cliutils/utils.go:626 +0x46

github.com/jfrog/jfrog-cli/artifactory.GetCommands.func41(0xc0002b4c60?)

        /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/artifactory/cli.go:635 +0x3d

github.com/urfave/cli.HandleAction({0xe247c0?, 0x1054028?}, 0x9?)

        /root/go/pkg/mod/github.com/urfave/[email protected]/app.go:524 +0x50

github.com/urfave/cli.Command.Run({{0xf91eee, 0x9}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xfda0ff, 0x20}, {0x0, ...}, ...}, ...)

        /root/go/pkg/mod/github.com/urfave/[email protected]/command.go:173 +0x65b

github.com/urfave/cli.(*App).RunAsSubcommand(0xc0000d8e00, 0xc0002b49a0)

        /root/go/pkg/mod/github.com/urfave/[email protected]/app.go:405 +0x927

github.com/urfave/cli.Command.startApp({{0xf8014e, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xfb8efb, 0x15}, {0x0, ...}, ...}, ...)

        /root/go/pkg/mod/github.com/urfave/[email protected]/command.go:378 +0x6e7

github.com/urfave/cli.Command.Run({{0xf8014e, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xfb8efb, 0x15}, {0x0, ...}, ...}, ...)

        /root/go/pkg/mod/github.com/urfave/[email protected]/command.go:102 +0x825

github.com/urfave/cli.(*App).Run(0xc0000d8c40, {0xc000034180, 0x3, 0x3})

        /root/go/pkg/mod/github.com/urfave/[email protected]/app.go:277 +0x8c7

main.execMain()

        /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/main.go:110 +0x353

main.main()

        /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/main.go:69 +0x25

Reproduction steps

  1. Add a new config with a wrong access token

jf config add --user YOUR-LOGIN --access-token BAD-TOKEN --url https://my-artifactory.url/ test

  1. Execute a jf cli command which need an authentication for exemple jf rt go-config. Select the test configuration with the bad access-token.

jf rt go-config

An error should appear, indicating that the identifier is incorrect for retrieving the list of repositories:


11:36:04 [🚨Error] failed getting repositories list: server response: 401 Unauthorized

{

  "errors": [

    {

      "status": 401,

      "message": "Bad credentials"

    }

  ]

}

Expected behavior

When we add a new configuration with a bad access token, an error message should appear indicating that the credentials are bad as the basic authentication method.


jf config add --user pvmk05211 --access-token bad-token --url https://my-artifactory.url/ test

[🚨Error] The following error was received while trying to encrypt your access token: Artifactory response: 401 Unauthorized

{

  "errors": [

    {

      "status": 401,

      "message": "Bad credentials"

    }

  ]

}

JFrog CLI version

2.29.2

Operating system type and version

Windows 10

JFrog Artifactory version

7.41.7

JFrog Xray version

3.55.2

@Romain0424 Romain0424 added the bug Something isn't working label Dec 16, 2022
@gorstak17
Copy link

try first jf login i had the same error like you and after i did jf login i could easily add new server configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants