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

fix: delete linked ssh keys correctly #3475

Merged
merged 1 commit into from
Jul 3, 2023
Merged

Conversation

tobybellwood
Copy link
Member

@tobybellwood tobybellwood commented Jul 3, 2023

In #3462 the routine used to delete a users ssh keys could error

Error: graphql: Cannot read properties of undefined (reading 'status')

This PR fixes the Knex logic to enable these deletes.

Tested by adding a key to a user, deleting user, and readding key to different user

tobybellwood@pop-os:~/sites/lagoon$ lagoon get user-sshkeys -E user@example.com
Info: No SSH keys for user 'user@example.com'
tobybellwood@pop-os:~/sites/lagoon$ lagoon add user-sshkey -E user@example.com  --keyvalue "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINA0ITV2gbDc6noYeWaqfxTYpaEKq7HzU3+F71XGhSL/ my-computer@example"
Result: success
id: 594
tobybellwood@pop-os:~/sites/lagoon$ lagoon get user-sshkeys -E user@example.com
EMAIL                   NAME                    TYPE            VALUE 
user@example.com  my-computer@example     ssh-ed25519     AAAAC3NzaC1lZDI1NTE5AAAAINA0ITV2gbDc6noYeWaqfxTYpaEKq7HzU3+F71XGhSL/
tobybellwood@pop-os:~/sites/lagoon$ lagoon add user-sshkey -E other.user@example.com  --keyvalue "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINA0ITV2gbDc6noYeWaqfxTYpaEKq7HzU3+F71XGhSL/ my-computer@example"
Error: graphql: (conn=81218, no: 1062, SQLState: 23000) Duplicate entry 'SHA256:FfrcVNHge/3iuS4pT5cMOWzb1SxOM5tFetDPIS+4neo' for key 'key_fingerprint'
tobybellwood@pop-os:~/sites/lagoon$ lagoon delete user -E user@example.com
✔ Yes
Result: success
tobybellwood@pop-os:~/sites/lagoon$ lagoon get user-sshkeys -E user@example.com
Info: No SSH keys for user 'user@example.com'
tobybellwood@pop-os:~/sites/lagoon$ lagoon add user-sshkey -E other.user@example.com  --keyvalue "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINA0ITV2gbDc6noYeWaqfxTYpaEKq7HzU3+F71XGhSL/ my-computer@example"
Result: success
id: 596
tobybellwood@pop-os:~/sites/lagoon$ lagoon get user-sshkeys -E other.user@example.com
EMAIL                   NAME                    TYPE            VALUE 
other.user@example.com my-computer@example     ssh-ed25519     AAAAC3NzaC1lZDI1NTE5AAAAINA0ITV2gbDc6noYeWaqfxTYpaEKq7HzU3+F71XGhSL/

Copy link
Member

@shreddedbacon shreddedbacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this works too

@tobybellwood tobybellwood merged commit 78e9675 into main Jul 3, 2023
@tobybellwood tobybellwood added this to the v2.15.2 milestone Jul 3, 2023
@tobybellwood tobybellwood deleted the fix_sshkey_delete branch July 24, 2023 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants