Skip to content

Conversation

@jphines
Copy link
Contributor

@jphines jphines commented May 7, 2019

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 hostmux that provides routing information using simple host matches as well as regexp host matches.

We also use a new SSOProxy struct as a constructor for use in main.go. Pulling this constructor out of main.go makes it easier to test and allows us to move more logic there.

@jphines jphines added the enhancement New feature or request label May 7, 2019
@jphines jphines self-assigned this May 7, 2019
Copy link
Contributor

@mccutchen mccutchen left a 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),
Copy link
Contributor

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...)

Copy link
Contributor Author

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 :)

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b930cc5

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.

@jphines jphines force-pushed the sso-refactor-hostmux branch from 3871f6d to 978e7db Compare May 8, 2019 17:50
}
}

func TestPing(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewritten and moved.

@jphines jphines force-pushed the sso-refactor-hostmux branch from b9170d8 to b930cc5 Compare May 9, 2019 16:44
mccutchen
mccutchen previously approved these changes May 9, 2019
Copy link
Contributor

@mccutchen mccutchen left a 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?

@jphines jphines force-pushed the sso-refactor-hostmux branch 3 times, most recently from 3fbda01 to 26bdf6d Compare May 15, 2019 17:34
@jphines jphines force-pushed the sso-refactor-hostmux branch from 26bdf6d to 07fa1b7 Compare May 15, 2019 22:39
Copy link
Contributor

@mccutchen mccutchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🚀 🚀 awesome work!

@jphines jphines merged commit 31da6e2 into master May 15, 2019
@jphines jphines deleted the sso-refactor-hostmux branch May 15, 2019 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants