-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Redis session store #155
Redis session store #155
Conversation
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.
This is great, though quite big 🙈 I've left some feedback on it inline, let me know what you think
pkg/sessions/redis/redis_store.go
Outdated
"github.com/pusher/oauth2_proxy/pkg/sessions/utils" | ||
) | ||
|
||
// TicketData is a structure representing a used in server session storage |
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.
This sentence doesn't make sense I don't think?
@brianv0 In order to push forward with this mini project, I did some work to rebase, clean up and integrate this code with the rest of the proxy, I've pushed my changes to the redis-session-store branch. I'm going to build an image from my branch and do some extended real world testing. I've been very granular with the commits I've added on top of yours, I would suggest you reset your branch to the head of my branch, push that to your fork so that we can maintain this PR and your attribution for the feature, and perhaps squash some of the commits as you see fit? I also did end up adding cookie signing to the redis implementation. We talked internally and decided that we would like to make signed cookies a requirement for all implementations to try and prevent brute force attacks on backends by guessing potential ticket names. There is a small performance impact though I think this should be minimal. Let me know if you have any questions about what I've done |
681590d
to
09d0a25
Compare
Thanks, you beat me to his looks great. I'm fine with the commit granularity and I don't feel a need to squash them but I'd be happy too if you want. On the I will do some testing but I might not be able to do much until next Monday. |
I updated the documentation and changelog. I wasn't sure if we should mention the storage type of |
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.
Hey @brianv0, I'm out at KubeCon this week so testing may be limited here too
I've added a couple of suggestions to improve the docs and still have one outstanding question about the clearing behaviour. Thanks for updating the docs btw, everything else is looking great now!
f84bfec
to
11a7ecf
Compare
Going to be testing this today, |
I found a bug when saving sessions where an existing expired session was present so I've added a test case and fixed it in 9dc1a96, pushing an updated image for retesting |
The result of my testing today has lead to another commit to be cherrypicked 48edce3, This one adds a test that the session should be stored in the persistent storage until the |
I forgot to mention, I think it is working now!!! Going to do a more widespread test across the Pusher infrastructure tomorrow and will report back! |
Okay great, I'll get those committed, I will be trying this out today hopefully as well. I think I had some code which may have been lost in translation and one of these might have been hard for me to see due to how long our tokens live in testing, but it sounds like we're close |
Found an issue in the session clearing which I've fixed in this commit 6d7f0ab |
One final thing 🙈 I noticed when attempting to deploy to a production system that there was no migration between different backends for the session storage and as such people had to clear cookies to make the proxy work. I added a test and a fix that should make this work in this commit 131206c But with that, we are now running a build from my branch redis-sessions-store on our production systems at Pusher and it seems to be working 🎉 |
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.
@brianv0 I'm happy with the implementation and testing that has been done on our side now.
If you could cherry pick the last few commits from our branch, then I think we are good to merge 🎉
a9815e9
to
4d39c7e
Compare
a808da3
to
405f9b3
Compare
Okay I think we're good now |
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! 🎉 Thanks for all your work and patience with me on this one @brianv0!
Description
Implements a redis-backed session store.
Cookies are implemented as tickets.
A ticket is composed of:
{CookieName}-{ticketID}.{secret}
Where:
CookieName
is the OAuth2 cookie name (_oauth2_proxy
by default)ticketID
is a 128 bit random number, hex-encodedsecret
is a 128 bit random number, base64 encodedThe pair of
{CookieName}-{ticketID}
comprises a ticket handle, and thus, the redis key. The handle is used to store an encoded session in redis viaSETEX
. The encoded session is encrypted according to thesecret
, which is unique for every session. This preserves the security aspects of oauth2_proxy.Motivation and Context
#138
How Has This Been Tested?
The session storage has been added to the suites for a session store. An additional behavior has been added to ensure the behavior that persistent keys, when cleared, are actually cleared.
Checklist: