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

Unload keys from agent upon logout. #1761

Merged
merged 1 commit into from
Mar 10, 2018
Merged

Conversation

russjones
Copy link
Contributor

Purpose

Unload keys from agent upon logout.

Implementation

  • Instead of operating on the filesystem keystore directly, operate on the key agent so keys can be unloaded from the agent upon logout.

Related Issues

Fixes #1541

@russjones russjones force-pushed the rjones/fix-logout-reg branch from 38585fe to 88361e4 Compare March 9, 2018 22:30
}

return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder why you decided to expand the one-liner this way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whenever I am reading code I always miss the one-liners since they don't follow the typical Go pattern calling a function then checking the return value.

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.

couple of comments

func (tc *TeleportClient) Logout() error {
return trace.Wrap(tc.localAgent.DeleteKey())
err := tc.localAgent.DeleteKey()
Copy link
Contributor

Choose a reason for hiding this comment

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

trace.Wrap(nil) returns nil so this change is not necessary

Copy link
Contributor Author

@russjones russjones Mar 9, 2018

Choose a reason for hiding this comment

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

This makes code substantially more readable. I can't count then number of times I've skipped over these one liners when reading code only to have to come back to them.

return nil
}

// LogoutAll removes all certificate for all users from the filesystem
Copy link
Contributor

Choose a reason for hiding this comment

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

all certificates

cf.Proxy = "dummy:1234"
tc, err := makeClient(cf, true)
if err != nil {
utils.FatalError(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would still prefer a return here.

tool/tsh/tsh.go Outdated
}

// Remove all keys from disk and the running agent.
err = tc.LogoutAll()
if err != nil {
fmt.Printf("Unable to remove all keys: %v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

if we failed here, why do we exit with 0 error code then?

@russjones russjones force-pushed the rjones/fix-logout-reg branch from 88361e4 to 5eddc32 Compare March 9, 2018 22:42
@kontsevoy
Copy link
Contributor

can this be merged?

@klizhentas
Copy link
Contributor

@kontsevoy yep

@kontsevoy kontsevoy merged commit 196fcc7 into master Mar 10, 2018
@kontsevoy kontsevoy deleted the rjones/fix-logout-reg branch March 10, 2018 06:15
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.

3 participants