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

API client Profile credential loader #5993

Merged
merged 1 commit into from
Mar 23, 2021
Merged

Conversation

Joerger
Copy link
Contributor

@Joerger Joerger commented Mar 15, 2021

Changes:

  • Add Profile Credential loader - automatically retrieves Dialer from profile.
  • Refactor Profile methods and functions into api/client/profile.go.

Merge after #5625, which this is based upon.

@Joerger Joerger changed the base branch from master to joerger/api-proxy-dialer March 15, 2021 16:18
@Joerger Joerger force-pushed the joerger/api-profile-credentials branch 4 times, most recently from cc5f20c to edc8a4b Compare March 17, 2021 19:41
@Joerger Joerger marked this pull request as ready for review March 17, 2021 19:57
@russjones
Copy link
Contributor

@awly @andrejtokarcik Can you review?

@Joerger Joerger force-pushed the joerger/api-profile-credentials branch from edc8a4b to 6212a10 Compare March 19, 2021 20:10
Comment on lines +165 to +166
sshCertPath := filepath.Join(userKeyDir, p.Username+constants.FileExtSSHCert)
err = ioutil.WriteFile(sshCertPath, []byte(sshCert), 0600)
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI this will need to be updated after #5938

Comment on lines +129 to 145
const (
// SessionKeyDir is the sub-directory where session keys are stored (.tsh/keys).
SessionKeyDir = "keys"
// FileNameKnownHosts is a file that stores known hosts.
FileNameKnownHosts = "known_hosts"
// FileExtTLSCert is the filename extension/suffix of TLS certs
// stored in a profile (./tsh/keys/profilename/username-x509.pem).
FileExtTLSCert = "-x509.pem"
// FileNameTLSCerts is the filename of Cert Authorities stored in a
// profile (./tsh/keys/profilename/certs.pem).
FileNameTLSCerts = "certs.pem"
// FileExtCert is a file extension used for SSH Certificate files.
FileExtSSHCert = "-cert.pub"
// FileExtPub is a file extension used for SSH Certificate Authorities
// stored in a profile (./tsh/keys/profilename/username.pub).
FileExtPub = ".pub"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

These constants aren't really used in the api module except for tests. Is the idea to gradually move everything from under lib/client to api/client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are also used in profile.go in profile.TLSConfig() and profile.SSHClientConfig(). We only want to move things that are essential to the API, but the majority of lib/client seems to be internal logic. I don't expect much more to be moved into api/client.

@Joerger Joerger force-pushed the joerger/api-profile-credentials branch from 4341deb to a0376ee Compare March 22, 2021 19:16
@Joerger Joerger requested a review from awly March 22, 2021 19:16
@Joerger Joerger force-pushed the joerger/api-profile-credentials branch from a0376ee to 1d773b3 Compare March 22, 2021 19:26
Copy link
Contributor

@russjones russjones left a comment

Choose a reason for hiding this comment

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

Bot.

@Joerger Joerger changed the base branch from joerger/api-proxy-dialer to master March 23, 2021 21:24
@Joerger Joerger force-pushed the joerger/api-profile-credentials branch from 1d773b3 to 35d4766 Compare March 23, 2021 22:33
@Joerger Joerger force-pushed the joerger/api-profile-credentials branch from 35d4766 to 40d31f2 Compare March 23, 2021 22:39
@Joerger Joerger enabled auto-merge (squash) March 23, 2021 22:39
@Joerger Joerger merged commit 32c4ae2 into master Mar 23, 2021
@Joerger Joerger deleted the joerger/api-profile-credentials branch March 23, 2021 23:35
Joerger added a commit that referenced this pull request Mar 30, 2021
* API client connection overhaul (#5625)

* Add Credential loader support for tsh profiles. (#5993)

* Profile credentials dialer fix (#6122)
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.

4 participants