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

LocalKeyAgent only loads keys for a user logged into a proxy. #1618

Merged
merged 1 commit into from
Jan 20, 2018

Conversation

russjones
Copy link
Contributor

@russjones russjones commented Jan 19, 2018

Purpose

#1541 and #1611 cover two problems tsh has. The first is that Teleport will use the incorrect key when trying to connect to a cluster if you use the same username across different proxies. The second issue is that Teleport does not log a user out correctly.

Implementation

  • GetKeys has been removed from LocalKeyAgent as it now only operates on a single user and proxy at a time. This was done to simplify the logic for LocalKeyAgent otherwise to fix tsh logout #1541 LocalKeyAgent would have to be updated to know about multiple proxies.
  • Added DeleteKeys to remove all keys to FSLocalKeyStore to remove all keys for all users connected to all proxies.
  • tsh logout without any parameters will call DeleteKeys and remove all keys for all users connected to all proxies.
  • tsh --proxy=one.example.com --user=rjones will log out rjones from one.example.com.

Related Issues

Fixes #1541
Fixes #1611

func (fs *FSLocalKeyStore) DeleteKeys() error {
dirPath := filepath.Join(fs.KeyDir, sessionKeyDir)

err := os.RemoveAll(dirPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

what if you logout twice this will be an error? probably should handle not found error on the upper level

Copy link
Contributor Author

@russjones russjones Jan 20, 2018

Choose a reason for hiding this comment

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

Doesn't return an error if called twice: https://golang.org/pkg/os/#RemoveAll

RemoveAll removes path and any children it contains. It removes everything
it can but returns the first error it encounters. If the path does not
exist, RemoveAll returns nil (no error).

tool/tsh/tsh.go Outdated
fmt.Printf("Logged out %v from %v.\n", cf.Username, proxyHost)
// remove all keys
case proxyHost == "" && cf.Username == "":
err = flka.DeleteKeys()
Copy link
Contributor

Choose a reason for hiding this comment

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

check NotFound condition here - tsh logout called twice should not result in error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DeleteKeys does not return an error. However, I cleaned up the error message when logging out a specific user a few lines up.

Copy link
Contributor

@klizhentas klizhentas left a comment

Choose a reason for hiding this comment

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

Have a couple of comments, see inline

@russjones russjones merged commit 14235ce into master Jan 20, 2018
@russjones russjones deleted the rjones/fix-lka branch January 20, 2018 02: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.

Teleport login problem tsh logout
3 participants