-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
8bc240b
to
19982e6
Compare
func (fs *FSLocalKeyStore) DeleteKeys() error { | ||
dirPath := filepath.Join(fs.KeyDir, sessionKeyDir) | ||
|
||
err := os.RemoveAll(dirPath) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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
19982e6
to
07e90d0
Compare
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 fromLocalKeyAgent
as it now only operates on a single user and proxy at a time. This was done to simplify the logic forLocalKeyAgent
otherwise to fix tsh logout #1541LocalKeyAgent
would have to be updated to know about multiple proxies.DeleteKeys
to remove all keys toFSLocalKeyStore
to remove all keys for all users connected to all proxies.tsh logout
without any parameters will callDeleteKeys
and remove all keys for all users connected to all proxies.tsh --proxy=one.example.com --user=rjones
will log outrjones
fromone.example.com
.Related Issues
Fixes #1541
Fixes #1611