[sql-18] sessions: tightly couple sessions & accounts#989
[sql-18] sessions: tightly couple sessions & accounts#989ellemouton merged 4 commits intolightninglabs:masterfrom
Conversation
d1b0cf8 to
66b8330
Compare
ViktorT-11
left a comment
There was a problem hiding this comment.
Generally looks great 🚀 !
I'd like to get some clarifications on the first commit thought, before ACKing :).
The last to comments are optional and non-blocking.
638c03c to
021daae
Compare
bitromortac
left a comment
There was a problem hiding this comment.
LGTM 🎉, have only a few nits
accounts/interceptor.go
Outdated
| string(caveatPrefix), | ||
| 2, | ||
| ) | ||
| if len(caveatSplit) == 2 { |
There was a problem hiding this comment.
strings.Cut could maybe be a nicer alternative here. Is it problematic if the macaroon has two account caveats?
There was a problem hiding this comment.
strings.Cut could maybe be a nicer alternative here.
nice!
There was a problem hiding this comment.
Is it problematic if the macaroon has two account caveats?
Yeah - but that would already be a problem today.
This commit is just a refactor of how the extraction logic already works.
Today, the interceptor would just match on the first account.
021daae to
d7f3859
Compare
When we link a session to an account, we want to be able to validate that the account actually does exist. So in preparation for that, we first give the session store access to the accounts store.
And use that from the existing accountFromMacaroon helper (which will then test the new helper by proxy). We add this helper so that we can use it later on from the sessions package where we want to extract an account ID from a caveat (we wont have a full macaroon available).
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.
d7f3859 to
bfb3c7b
Compare
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.
This is in preparation for adding a SQL implementation of the session Store
where this link will be done at a relational DB level.
part of #966