feat(BRE2-1051): ssh certs uptake - #452
Conversation
3d5b905 to
e719698
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #452 +/- ##
==========================================
+ Coverage 24.67% 26.20% +1.52%
==========================================
Files 134 137 +3
Lines 18337 18858 +521
==========================================
+ Hits 4525 4942 +417
- Misses 13335 13400 +65
- Partials 477 516 +39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f1c4114 to
9b4209d
Compare
Foundation for certificate-based SSH auth. Generates fresh ed25519
keypairs per renewal, caches the (private key, certificate) pair on
disk for the certificate's validity window, and writes atomically
(0600 private key). Files live under ~/.brev/ssh-certs/<envID>{,-cert.pub}
so a single IdentityFile directive loads both key and cert (OpenSSH
-cert.pub convention).
Independent of the IssueEnvironmentSSHCertificate RPC so the rest of
the feature can build and test before the generated connect client is
published. Includes EnvironmentCertEligible() mirroring dev-plane's
label constants (sshprovider=certauth).
9b4209d to
80057f4
Compare
| }) | ||
| }, | ||
| } | ||
| cmd.Flags().StringVar(&env, "env", "", "environment ID to mint a certificate for") |
There was a problem hiding this comment.
Should we keep this vague (similar to ssh, which is "the name or ID") so that we could possibly support external nodes with the same command?
| } | ||
|
|
||
| func makeSSHConfigEntryV2(workspace entity.Workspace, privateKeyPath string, cloudflaredBinaryPath string) (string, error) { //nolint:funlen,gocyclo // ok | ||
| var isSSHCertRequired = analytics.IsSSHCertRequired |
There was a problem hiding this comment.
Is this so that it can be mocked?
| } | ||
|
|
||
| sshConfig, err := makeNewSSHConfig(toWindowsPath(configPath), workspaces, toWindowsPath(pkpath), toWindowsPath(cloudflaredBinaryPath)) | ||
| sshConfig, err := makeNewSSHConfig(toWindowsPath(configPath), workspaces, toWindowsPath(pkpath), toWindowsPath(cloudflaredBinaryPath), false) |
There was a problem hiding this comment.
Could we pass a const or enum for this final boolean?
| return now.Add(margin).Unix() < notAfter | ||
| } | ||
|
|
||
| func HasValidCertAt(fs afero.Fs, certPath string, now time.Time, margin time.Duration) (bool, error) { |
There was a problem hiding this comment.
Should we similarly check that the private key is sound / paired to the public key that this cert was issued for ?
| {{ end }} | ||
| ` | ||
|
|
||
| const SSHCertRequiredTemplateV2 = `Match host {{ .Alias }} exec {{ .ExecCommand }} |
There was a problem hiding this comment.
Do the exec commands need to be quoted (and below)?
Uh oh!
There was an error while loading. Please reload this page.