-
Notifications
You must be signed in to change notification settings - Fork 109
sessions: delete session after registration failure #1174
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1213,6 +1213,18 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context, | |
| return nil, fmt.Errorf("error creating new session: %v", err) | ||
| } | ||
|
|
||
| // If we tried to link to a previous session, we delete the newly | ||
| // created session in the case of errors to avoid having non-revoked | ||
| // sessions lying around. | ||
| fail := func(err error) error { | ||
| if len(req.LinkedGroupId) != 0 { | ||
| err := s.cfg.db.DeleteReservedSession(ctx, sess.ID) | ||
| log.Errorf("error deleting session after failed "+ | ||
| "linking attempt: %v", err) | ||
| } | ||
| return err | ||
| } | ||
|
|
||
| // If this session is being linked to a previous one, then we need to | ||
| // use the previous session's local private key to sign the new | ||
| // session's public key in order to prove to the Autopilot server that | ||
|
|
@@ -1286,8 +1298,8 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context, | |
| privacyFlags.Serialize(), | ||
| ) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error registering session with "+ | ||
| "autopilot server: %v", err) | ||
| return nil, fail(fmt.Errorf("error registering session with "+ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we're not 100% sure here that this errors due to the session not having been stored on the autopilot server (as this could simplify fail for loss of the connection mid execution for example), I can see the motivation still persisting this on the |
||
| "autopilot server: %v", err)) | ||
| } | ||
|
|
||
| err = s.cfg.db.UpdateSessionRemotePubKey(ctx, sess.ID, remoteKey) | ||
|
|
||
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.
Nit: Not sure we need a separate lambda function for this when it's only being called once?
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.
right, I wasn't sure if we also want to delete the session on an error later on, so I left it for now