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

knife user create with --user-key option fails to create user #14681

Open
drewhammond opened this issue Oct 30, 2024 · 0 comments · May be fixed by #14682
Open

knife user create with --user-key option fails to create user #14681

drewhammond opened this issue Oct 30, 2024 · 0 comments · May be fixed by #14682
Labels
Status: Untriaged An issue that has yet to be triaged.

Comments

@drewhammond
Copy link

Description

When creating a user with knife, the --user-key option does not work as intended. I expect to be able to provide the path of a public key and it will create the user without generating a new private key on the server, but instead it fails to create the user entirely.

There are two bugs:

  1. In the API request (POST /users), a create_key field is sent with null value and the server complains because it expects a boolean value:
➜  ~ knife user create testuser --email '[email protected]' --password testpass --orgname example --user-key /path/to/key.pub
ERROR: The data in your request was invalid
Response: Field 'create_key' invalid

The raw API response is:

{"error":["Field 'create_key' invalid"]}
  1. The contents of the --user-key file are never sent along in the API request
{
  "username": "testuser",
  "first_name": "",
  "last_name": "",
  "display_name": "testuser",
  "email": "[email protected]",
  "password": "testpass",
  "create_key": null
}

Based on the API documentation, I would expect create_key to be omitted (or false), and a new field public_key to contain the public key as a string.

Chef Version

➜  ~ knife --version
Cinc Client: 18.5.0
➜  ~ cinc version
Cinc Workstation version: 24.8.1068
Test Kitchen version: 3.6.0
Cookstyle version: 7.32.8
Cinc Client version: 18.5.0
Cinc Auditor version: 5.22.55
Cinc CLI version: 5.6.14
Biome version: unknown
root@test-server:~# cinc-server-ctl version
15.9.38

Platform Version

MacOS 14.5 (23F79) - arm64

Replication Case

  1. Generate a keypair locally:
openssl genrsa -out test.pem 2048
openssl rsa -in test.pem -pubout -out test.pub
  1. Attempt to use knife to create the user with the previously generated public key:
knife user create testuser --email '[email protected]' --password testpass --orgname example --user-key test.pub
  1. Observe error

Client Output

ERROR: The data in your request was invalid
Response: Field 'create_key' invalid
@drewhammond drewhammond added the Status: Untriaged An issue that has yet to be triaged. label Oct 30, 2024
@drewhammond drewhammond linked a pull request Oct 31, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Untriaged An issue that has yet to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant