-
Notifications
You must be signed in to change notification settings - Fork 189
sso-proxy: refactor routing into hostmux, refactor oauthproxy startup #190
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
mccutchen
left a comment
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.
I really like the direction we're heading here @jphines! I took a first pass and left some comments below. Mostly questions, along with a few highly opinionated and possibly misguided suggestions.
| optFuncs = append(optFuncs, | ||
| SetCookieStore(opts), | ||
| SetUpstreamConfig(upstreamConfig), | ||
| SetProxyHandler(handler), |
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.
SetProxyHandler strikes me as a bad use of functional options, because a handler is not an optional piece of an OAuthProxy instance. My vote would be to change the signature of NewOAuthProxy to take a handler as its first argument:
oauthproxy, err := NewOAuthProxy(handler, opts, optFuncs...)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.
It's particularly nice for testing though :)
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.
Do we have a lot of tests where we don't need a handler set up? Can we paper over that in a testing helper function?
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.
I've added this commit to add error messages if the NewOAuthProxy does is not properly configured.
I think this is a nice compromise between the func options as well as ensuring the oauthproxy we return is functional.
3871f6d to
978e7db
Compare
| } | ||
| } | ||
|
|
||
| func TestPing(t *testing.T) { |
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.
Rewritten and moved.
b9170d8 to
b930cc5
Compare
mccutchen
left a comment
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 @jphines, I think this significantly improves our ability to test and further expand sso's features and functionality. Thanks for bearing with me on this long review process!
Given how significant and fundamental these changes are, how would you feel about letting them soak on our infrastructure for a bit before we land them here?
3fbda01 to
26bdf6d
Compare
26bdf6d to
07fa1b7
Compare
mccutchen
left a comment
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.
🚀 🚀 🚀 awesome work!
Problem
OAuthProxy currently manages all of our routing information, upstream configs, provider information, etc. This made sense as we incrementally built SSO and wanted to make as minimal changes as possible during the development cycle.
However, SSO today is quite different and has various needs to be easier to extend.
Uncoupling routing, upstream configuration, and provider information from being closely tied to the OAuth layer will help in this uncoupling.
Solution
We two higher layer structs to help simplify the component structure as well as testing. We had a high level
hostmuxthat provides routing information using simple host matches as well as regexp host matches.We also use a new
SSOProxystruct as a constructor for use inmain.go. Pulling this constructor out ofmain.gomakes it easier to test and allows us to move more logic there.