uselagoon / lagoon

Lagoon, the developer-focused application delivery platform
https://docs.lagoon.sh/
Apache License 2.0
560 stars 149 forks source link

feat: use api-sidecar-handler to offload sshkey handling and add more types #3662

Closed shreddedbacon closed 3 months ago

shreddedbacon commented 7 months ago

General Checklist

Database Migrations

The node package sshpk doesn't support all the various key types out there. The aim of this PR is to introduce a sidecar to required services that runs a simple http server that can replace the functionality of the sshpk package.

Each api and webhooks2tasks pod will get this sidecar so that they aren't reliant on a single service for this functionality, and as there is no state it doesn't need to be a single service and fits nicely as a sidecar.

It introduces new APIs to interact with user ssh keys that doesn't require the user to define the type independently. The input is just publicKey which can be the full ssh-ed25519 A....z format public key (including comment). The database table for the type is also converted from enum to string to support any new types, and since the older APIs had enum enforcement, that still applies for anyone that uses the older APIs.

The old APIs remain for now, but have been flagged as deprecated. They will be removed in a future release to give time for tooling and UI to be updated to use the newer APIs.

New mutation examples

Add public key

addUserSSHPublicKey(input: {
  name: "my-users-publickey-example"
  publicKey: "ssh-rsa AAAAB3NzaC1yc2EA<SNIP>LOiWw=="
  user: {
    email: "my-user@example.com"
  }
}) {
  id
}

Update public key

updateUserSSHPublicKey(input: {
  id: 1
  patch: {
    publicKey: "ssh-rsa AAAAB3NzaC1yc2EA<SNIP>LOiWw=="
  }
}) {
  id
}

Delete public key

deleteUserSSHPublicKey(input: {
    id: 1
})

Closing issues

closes #2189 closes #1584 addresses #2384 by deprecating deleteSshKey which takes the name input