Commit graph

53 commits

Author SHA1 Message Date
bitromortac
a18c0b656f
session: implement DeleteReservedSession 2025-11-25 19:35:42 +01:00
Elle Mouton
4f8c3aec16
firewalldb+rpcserver: refactor ListActions
Here we move the filter logic behind the interface so that our sql
implementation can make use of indexes.
2025-05-09 13:57:10 +02:00
Elle Mouton
b82e01edf4
session: update session remote pub by session ID
It's a better pattern to refer to sessions in the same way consistently.
So we update the UpdateSessionRemotePubKey method to use a session ID as
a reference to the session instead of local pub key.
2025-03-04 17:39:03 +02:00
Elle Mouton
190d3dc828
multi: rename GetSessionByID to GetSession
By default, we fetch records by an ID.
2025-03-04 17:34:31 +02:00
Elle Mouton
1ba381cead
session: rename GetSession method
Rename it to GetSessionByLocalPub so that it is more accurately named
and so that we free up the GetSession name for future use.
2025-03-04 17:30:43 +02:00
Elle Mouton
8a34189b45
session: assert account exists before linking a session to it
In this commit, we more tightly & explicitly link a session to an
account. At a persitance layer, we have always only linked a session to
an account by encoding the AccountID within the macaroon caveat that we
store with the session. We still keep this persistence the same but now
we first ensure that the account exists and we also add an AccountID
field to the Session struct.
2025-03-04 13:43:42 +02:00
Elle Mouton
306519fd6d
session: remove variadic State param from ListSessionsByState
We only really ever use it in one place and even then, only for a
session State that we no longer use anymore.

This is done to make the SQL queries we will need to implement the SQL
Store more simple.
2025-03-02 13:27:14 +02:00
Elle Mouton
01c19c5172
session: add context to UpdateSessionRemotePubKey 2025-02-28 09:26:02 +02:00
Elle Mouton
f93093e7c9
session: add context to ShiftState 2025-02-28 09:26:02 +02:00
Elle Mouton
aa7b1db207
session: pass contexts through to all IDToGroupIndex methods 2025-02-28 09:26:02 +02:00
Elle Mouton
9642ce1656
session+firewall: pass context to GetSessionByID 2025-02-28 09:26:02 +02:00
Elle Mouton
aa5674cabd
session: add context to DeleteReservedSessions 2025-02-28 09:24:42 +02:00
Elle Mouton
7c30c510a1
session: add context to various session List methods 2025-02-28 09:24:42 +02:00
Elle Mouton
310f11acda
session: add context to GetSession 2025-02-28 09:24:41 +02:00
Elle Mouton
2dda9308b6
session: pass context to NewSession 2025-02-28 09:24:10 +02:00
Elle Mouton
b81742fe9d
session: functional options for NewSession
For a cleaner interface, adjust the NewSession method of the Session
store such that all optional arguments are functional options.
2025-02-27 15:00:02 +02:00
Elle Mouton
32a34d1245
session: remove Session Group Predicate method
This was used to check that all linked sessions are no longer
active before attempting to register an autopilot session. But this is
no longer needed since this is done within NewSession.
2025-02-26 18:32:13 +02:00
Elle Mouton
013e7c081c
session: introduce Reserve->Create pattern
In this commit, we let StateReserved be the new initial state of a
session for when NewSession is called. We then do predicate checks for
linked sessions along with unique session alias (ID) and priv key
derivations all under the same DB transaction in NewSession.

ShiftState then moves a session to StateCreated. Only in StateCreated
does a session become usable.

With this change, we no longer need to ensure atomic session creation by
acquiring the `sessRegMu` mutex in the session RPC server.
2025-02-26 18:32:12 +02:00
Elle Mouton
1ed4907097
session: replace RevokeSession with ShiftState 2025-02-25 16:23:07 +02:00
Elle Mouton
8f22fc98a0
session: add ShiftState method to session Store
And only allow legal state shifts.
2025-02-25 16:23:06 +02:00
Elle Mouton
6717d9d54b
session+lnrpc: add StateReserved and delete these on start up 2025-02-19 12:09:27 -03:00
Elle Mouton
68ae704229
session: add comments to the session.State types 2025-02-17 04:29:35 -03:00
Elle Mouton
d2b077b9d5
session: add ListSessionsByState method 2025-02-13 15:28:23 +02:00
Elle Mouton
01410f7950
session: remove the filter fn in ListSessions
And replace with ListAllSessions since no callers of ListSessions
currently make use of the filter function.
2025-02-13 15:22:28 +02:00
Elle Mouton
6c36b01fd8
session: add ListSessionsByType method
And use it to replace one call to ListSessions which uses a filter
function which would be inefficient in SQL land.
2025-02-13 15:13:00 +02:00
Elle Mouton
64f79617e4
session: use clock for times
And be consistent with UTC conversions.
2025-02-11 19:22:08 +02:00
Elle Mouton
e923fff46c
session: add NewSession to Store interface
For now, it makes no DB calls. But this is in prepartion for letting
this call persist a new session. This will also let us use a shared
`clock` for the time fields in a Session.
2025-02-11 19:19:11 +02:00
Elle Mouton
402373cfca
session: move MacaroonBaker to macaroons package
Move the MacaroonBaker type to the new macaroons package to avoid import
cycles in future.
2025-02-09 10:56:23 +02:00
Elle Mouton
4d22dfb7e9
multi: refactor to not use session.MacaroonRecipe outside the package
In this commit, we refactor various uses of the session.MacaroonRecipe
type outside of the session package. This is to decouple the baking of a
super macaroon from the sessions package and will help avoid import
cycles in future.
2025-02-09 10:45:10 +02:00
Elle Mouton
949c0bf7e2
multi: move macaroon helpers to macaroons dir
... and out of the `sessions` directory. This is to avoid import cycles
when we start explicitly linking accounts to sessions.
2025-02-09 10:37:40 +02:00
bitromortac
1e83df2225
session: add privacy flags to session tlvs
Privacy flags are stored within the session.
2024-04-25 14:49:45 +02:00
Elle Mouton
71cac8672f
session: add a CheckSessionGroupPredicate method
This method can be used to check that each session in a group passes for
a given predicate.
2023-08-30 12:34:29 +02:00
Elle Mouton
cc95a01923
session: add GetGroupID and GetSessionIDs methods
This commit adds new getters: `GetGroupID` and `GetSessionIDs` to the
session store which can be used to query the newly added indexes to get
the associated group ID for a session ID or the associated set of
session IDs for a group ID.
2023-08-30 12:34:28 +02:00
Elle Mouton
4bd8a5c03a
session: add GroupID field to Session
Add the new `GroupID1` field to the `Session` struct and ensure that the
new fields are properly serialised and deserialised.  The `GroupID` is
the ID of the first Session in a set of linked sessions.
2023-08-30 11:46:33 +02:00
Elle Mouton
c8b78bd10d
session: add new ID-to-key index
This commit does a few things:

1. Instead of deriving IDs using the first 4 bytes of the session's
   serialised local pub key, we instead use bytes [1:5] in order to skip
   the first byte which is either 0x02 or 0x03. This results in a
   greater entropy set.
2. We also add a new index from ID to key and we write to this index
   each time a new session is added.
3. We add a `ReserveNewSessionID` method to the session store which will
   grind through private keys until it finds one that does not clash
   with the current ID set.
4. A migration is added to back-fill the ID-to-key index. If any old
   sessions are found that _do_ have a colliding ID, they are sorted by
   created time and all but the newest session is revoked. Only an entry
   for the newest session will be added to the ID-to-key index.
2023-08-30 11:46:33 +02:00
Elle Mouton
d3a262600f
session: separate methods for creating vs updating a session 2023-08-25 16:02:13 +02:00
Elle Mouton
92575c8ed7
session: update the session Store interface 2023-08-25 14:20:12 +02:00
Elle Mouton
3b67325360
multi: implement lit-autopilot rpc server 2023-01-27 06:47:13 +02:00
Elle Mouton
5255e952d8
session: add WithPrivacy to Session type 2023-01-27 06:47:13 +02:00
Elle Mouton
4639e7e5ba
session+rpcserver: add feature config to session type 2023-01-27 06:47:13 +02:00
Elle Mouton
78c996a7a1
multi: add Session ID to struct
This commit adds an ID to the Session struct. The ID is not persisted
but is instead derived from the macaroon used for the session.
2023-01-27 06:47:10 +02:00
Elle Mouton
b73c3699d6
session: add RevokedAt field
This commit adds a RevokedAt field to the Session structure and sets the
value of the field to the current time when RevokeSession is called.
2023-01-10 10:43:26 +02:00
Elle Mouton
0311de1cb7
multi: change account session type and reserve type 4
In this commit, the Account session type is changed to be type 5 in
both the session proto and in the persisted Session. This is done so
that type 4 can be reserved for future use.
2022-12-06 12:50:27 +02:00
Oliver Gugger
fc4f4a4cca
multi: add account based LNC sessions 2022-12-02 10:10:02 +01:00
Oliver Gugger
cd741091be
session+accounts: add RPC server 2022-12-02 10:06:51 +01:00
Elle Mouton
d23073f8b0
litrpc+session: add CreatedAt member to Session 2022-08-18 18:37:44 +02:00
Oliver Gugger
1444e7a180
multi: bump all dependencies to latest versions 2022-06-24 16:18:14 +02:00
Oliver Gugger
472d8f4602
multi: persist remote static key for handshakev2
This commit re-enables the second handshake for LNC.
2022-06-23 10:32:43 +02:00
Oliver Gugger
30d13ff7bb
Revert "multi: persist remote static key for handshakev2"
This reverts commit 31713c6e3d.
We will bump LNC to the latest version once the Terminal Web UI is ready
to persist the keys as well.
2022-04-20 14:42:26 +02:00
Elle Mouton
31713c6e3d
multi: persist remote static key for handshakev2
In this commit, we update the go mod to point to the version of LNC that
contains the logic for handshake version 2. This requires that we pass
in a call back that LNC can call to persist the remote static key once
it is received. This then needs to be provided each time we start up the
session again.
2022-04-19 09:49:08 +02:00