Campaigns cannot be applied as a normal user when the code host is configured to use SSH to clone repositories
Created by: LawnGnome
This occurs because gitserver
will attempt to inject the user credential into the ssh://
URL, which causes Git to be unable to parse the URL, after which a spurious "host not found" error is returned. This is a lie, but the issue is real.
Plan of attack
At a high level, we can deal with this by detecting code hosts with this configuration, then prompting users to add a public key (which we can generate and store) to their account when adding a PAT.
In terms of issues, this breaks down into:
- Add an SSH key credential type. (By making it a credential type, we can reuse existing progress towards securing secrets.)
- Generate a private key on demand and store it in the database.
- Design the modified user settings flow to support this.
- Update the GraphQL schema to handle multiple credentials and detect when SSH keys are required.
- Update the user settings UI to provide the appropriate CTA and prompt with the public key.
- Update
gitserver
to use an SSH key credential instead of a PAT credential when pushing over SSH. - Document how users can configure this.
A bonus quest later might be to automatically provision the key into the code host if the user scopes their PAT to allow this.