-
Notifications
You must be signed in to change notification settings - Fork 103
[sql-18] sessions: tightly couple sessions & accounts #989
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
Conversation
d1b0cf8
to
66b8330
Compare
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.
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
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.
uTACK LGTM 🚀🎉
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.
LGTM 🎉, have only a few nits
accounts/interceptor.go
Outdated
string(caveatPrefix), | ||
2, | ||
) | ||
if len(caveatSplit) == 2 { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings.Cut could maybe be a nicer alternative here.
nice!
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.
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