-
Notifications
You must be signed in to change notification settings - Fork 103
sessions: strict state shifts #985
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8f22fc9
session: add ShiftState method to session Store
ellemouton 1ed4907
session: replace RevokeSession with ShiftState
ellemouton 3272dda
session_rpcserver: use the Expired state for expired sessions
ellemouton ec8d136
docs: add release notes
ellemouton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Release Notes | ||
|
||
- [Lightning Terminal](#lightning-terminal) | ||
- [Bug Fixes](#bug-fixes) | ||
- [Functional Changes/Additions](#functional-changesadditions) | ||
- [Technical and Architectural Updates](#technical-and-architectural-updates) | ||
- [Integrated Binary Updates](#integrated-binary-updates) | ||
- [LND](#lnd) | ||
- [Loop](#loop) | ||
- [Pool](#pool) | ||
- [Faraday](#faraday) | ||
- [Taproot Assets](#taproot-assets) | ||
- [Contributors](#contributors-alphabetical-order) | ||
|
||
## Lightning Terminal | ||
|
||
### Bug Fixes | ||
|
||
### Functional Changes/Additions | ||
|
||
### Technical and Architectural Updates | ||
|
||
* Correctly [move a session to the Expired | ||
state](https://github.com/lightninglabs/lightning-terminal/pull/985) instead | ||
of the Revoked state if it is in fact being revoked due to the session expiry | ||
being reached. | ||
|
||
|
||
## RPC Updates | ||
|
||
## Integrated Binary Updates | ||
|
||
### LND | ||
|
||
### Loop | ||
|
||
### Pool | ||
|
||
### Faraday | ||
|
||
### Taproot Assets | ||
|
||
# Contributors (Alphabetical Order) | ||
|
||
* Elle Mouton |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,8 +154,8 @@ func (s *sessionRpcServer) start(ctx context.Context) error { | |
err) | ||
|
||
if perm { | ||
err := s.cfg.db.RevokeSession( | ||
sess.LocalPublicKey, | ||
err := s.cfg.db.ShiftState( | ||
sess.ID, session.StateRevoked, | ||
) | ||
if err != nil { | ||
log.Errorf("error revoking "+ | ||
|
@@ -360,7 +360,8 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context, | |
log.Debugf("Not resuming session %x with expiry %s", | ||
pubKeyBytes, sess.Expiry) | ||
|
||
if err := s.cfg.db.RevokeSession(pubKey); err != nil { | ||
err := s.cfg.db.ShiftState(sess.ID, session.StateExpired) | ||
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. 👍 |
||
if err != nil { | ||
return fmt.Errorf("error revoking session: %v", err) | ||
} | ||
|
||
|
@@ -436,7 +437,9 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context, | |
log.Debugf("Deadline for session %x has already "+ | ||
"passed. Revoking session", pubKeyBytes) | ||
|
||
return s.cfg.db.RevokeSession(pubKey) | ||
return s.cfg.db.ShiftState( | ||
sess.ID, session.StateRevoked, | ||
) | ||
} | ||
|
||
// Start the deadline timer. | ||
|
@@ -515,7 +518,7 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context, | |
log.Debugf("Error stopping session: %v", err) | ||
} | ||
|
||
err = s.cfg.db.RevokeSession(pubKey) | ||
err = s.cfg.db.ShiftState(sess.ID, session.StateRevoked) | ||
if err != nil { | ||
log.Debugf("error revoking session: %v", err) | ||
} | ||
|
@@ -557,7 +560,13 @@ func (s *sessionRpcServer) RevokeSession(ctx context.Context, | |
return nil, fmt.Errorf("error parsing public key: %v", err) | ||
} | ||
|
||
if err := s.cfg.db.RevokeSession(pubKey); err != nil { | ||
sess, err := s.cfg.db.GetSession(pubKey) | ||
if err != nil { | ||
return nil, fmt.Errorf("error fetching session: %v", err) | ||
} | ||
|
||
err = s.cfg.db.ShiftState(sess.ID, session.StateRevoked) | ||
if err != nil { | ||
return nil, fmt.Errorf("error revoking session: %v", err) | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Would also be value in testing that shifting a
StateReserved
session toStateRevoked
is not legal, as that's the concern in the comment that this PR is addressing :). Potentially also add coverage to show thatStateInUse
->StateRevoked
is legal.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.
personally, i think we only need to test illegal state transitions once and not for every possible iteration