-
Notifications
You must be signed in to change notification settings - Fork 184
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
sso-proxy: adding an optional PROXY_PROVIDER_URL for split dns deployments #88
Conversation
0362612
to
2178477
Compare
working on this error maybe on the sso_auth side:
|
5762ed9
to
8fbf65b
Compare
ok, so this is working now. now need to actually pass the values from the config to the function. |
435de59
to
6fe9d49
Compare
ok, got values making their way into the functions, just got to fixup tests. |
774d874
to
a9e50a2
Compare
49a0add
to
d1008ef
Compare
internal/proxy/providers/sso_test.go
Outdated
@@ -253,9 +283,11 @@ func TestSSOProviderGetEmailAddress(t *testing.T) { | |||
p.ProfileURL, profileServer = newTestServer(http.StatusOK, body) | |||
} else { | |||
p.RedeemURL, profileServer = newCodeTestServer(400) | |||
p.ProxyRedeemURL, redeemServer = newCodeTestServer(400) |
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.
might need to defer this server being closed as well
internal/proxy/providers/sso_test.go
Outdated
RefreshToken: "refresh12345", | ||
Email: "michael.bland@gsa.gov", | ||
}, | ||
ProxyProviderURL: &url.URL{ |
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 think what you'd want to do to test this behavior is create a ProxyProviderResponse
similar to the Redeem Response and Profile Response, as well as a ProxyRedeemResponse
, and assign the server urls to those provider fields. Then you can test that the endpoints are being hit based on the response.
internal/proxy/providers/sso_test.go
Outdated
} else { | ||
p.RedeemURL, redeemServer = newCodeTestServer(400) | ||
p.ProxyRedeemURL, redeemServer = newCodeTestServer(400) |
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.
similar to @shrayolacrayon 's comment above, why do we need to create the test server twice here?
ac9ac27
to
ffbc8a9
Compare
5e2d6a5
to
dec5586
Compare
internal/proxy/options_test.go
Outdated
{ | ||
name: "redeem string based on proxyProviderURL", | ||
providerURLString: "https://provider.example.com", | ||
proxyProviderURLString: "https://provider-internal.example.com", |
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 this field being used anywhere?
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.
@shrayolacrayon it's the string that we use to generate the proxyProviderURL
url
Lines 223 to 226 in dec5586
proxyProviderURL, err := url.Parse(o.ProxyProviderURLString) | |
if err != nil { | |
return err | |
} |
sso/internal/proxy/providers/sso.go
Line 63 in dec5586
p.ProxyRedeemURL = p.ProxyProviderURL.ResolveReference(&url.URL{Path: "/redeem"}) |
internal/proxy/options_test.go
Outdated
@@ -16,7 +16,7 @@ func testOptions() *Options { | |||
o.ClientSecret = "xyzzyplugh" | |||
o.EmailDomains = []string{"*"} | |||
o.ProviderURLString = "https://www.example.com" | |||
o.ProxyProviderURLString = "https://internal.example.com" | |||
o.ProxyProviderURLString = "" |
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.
you don't need to set this to be empty, it'll default to an empty string
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.
removed
7b880b0
to
b1ce2a6
Compare
39acd6b
to
f33791d
Compare
@@ -19,6 +19,7 @@ import ( | |||
// Options are configuration options that can be set by Environment Variables | |||
// Port - int - port to listen on for HTTP clients | |||
// ProviderURLString - the URL for the provider in this environment: "https://sso-auth.example.com" | |||
// ProxyProviderURLString - the internal URL for the provider in this environment: "https://sso-auth-int.example.com" |
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.
If this field is truly intended as an internal URL, would it be clearer if the name reflected that? I struggle a little bit with the names ProviderURLString
and ProxyProviderURLString
being not meaningfully different as far as I can tell.
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.
thought here is that the sso_proxy
service is using this one, the other is for the client
. but then naming is not my strong suit
var redeemServer *httptest.Server | ||
var redeemServerInternal *httptest.Server | ||
// set up redemption resource | ||
if tc.RedeemResponseInternal != nil { |
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.
why aren't we marshaling the redeem response if RedeemResponseInternal
is nil?
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 copied from the existing tests so i had not put much thought into it:
sso/internal/proxy/providers/sso_test.go
Lines 260 to 266 in 7898834
if tc.RedeemResponse != nil { | |
testutil.Equal(t, nil, err) | |
testutil.NotEqual(t, session, nil) | |
testutil.Equal(t, tc.RedeemResponse.Email, session.Email) | |
testutil.Equal(t, tc.RedeemResponse.AccessToken, session.AccessToken) | |
testutil.Equal(t, tc.RedeemResponse.RefreshToken, session.RefreshToken) | |
} |
from what i can see it looks like the test cases are divided into two classes, those that don't produce a redeem response, and ones that should produce a valid redeem response which then gets checked for validity. for this particular test, i'm testing to see that the code is handling the case where both the RedeemURL
and ProxyRedeemURL
both exist. in that case the internal ProxyRedeemURL
should be used for the redeem.
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.
Oh got it, I didn't see that we're still testing RedeemResponse above.
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.
added one more error nit, but other than that this lgtm!
1d04389
to
af20521
Compare
sso-proxy: adding an optional PROXY_PROVIDER_URL for split dns deployments
addressing: #26