Skip to content
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

fix(server): Fix issue with auto oauth redirect URL in callback and handle proxies #6175

Merged
merged 3 commits into from
Jun 22, 2021

Conversation

stefansedich
Copy link
Contributor

Turns out I didn't quite get #6167 quite right, two things needed to be addressed:

  1. Looking at just s.secure to decide if we use http or https for the callback falls down when we are behind a proxy and are not running in secure mode
  2. I did not correctly pass the generated callback URI when fetching the token in the callback

This PR addresses the two issues above and ensures things actually work as I originally intended.

Checklist:

@stefansedich stefansedich marked this pull request as ready for review June 18, 2021 00:44
@stefansedich
Copy link
Contributor Author

stefansedich commented Jun 18, 2021

@alexec this one will be needed too, sorry about that I goofed with the first PR and turns out I had not quite gotten things right, teach me for not testing properly 😢

@codecov
Copy link

codecov bot commented Jun 18, 2021

Codecov Report

Merging #6175 (662bc8d) into master (0cc5a24) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6175      +/-   ##
==========================================
- Coverage   47.55%   47.53%   -0.02%     
==========================================
  Files         250      250              
  Lines       15806    15809       +3     
==========================================
- Hits         7516     7515       -1     
+ Misses       7353     7352       -1     
- Partials      937      942       +5     
Impacted Files Coverage Δ
server/auth/sso/sso.go 26.79% <0.00%> (-0.54%) ⬇️
cmd/argo/commands/get.go 56.45% <0.00%> (-0.65%) ⬇️
workflow/controller/operator.go 70.84% <0.00%> (-0.28%) ⬇️
server/workflow/workflow_server.go 44.28% <0.00%> (+1.14%) ⬆️
workflow/metrics/server.go 16.66% <0.00%> (+4.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0cc5a24...662bc8d. Read the comment docs.

@@ -307,8 +308,8 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe
mux.HandleFunc("/input-artifacts/", artifactServer.GetInputArtifact)
mux.HandleFunc("/artifacts-by-uid/", artifactServer.GetOutputArtifactByUID)
mux.HandleFunc("/input-artifacts-by-uid/", artifactServer.GetInputArtifactByUID)
mux.HandleFunc("/oauth2/redirect", as.oAuth2Service.HandleRedirect)
mux.HandleFunc("/oauth2/callback", as.oAuth2Service.HandleCallback)
mux.Handle("/oauth2/redirect", handlers.ProxyHeaders(http.HandlerFunc(as.oAuth2Service.HandleRedirect)))
Copy link
Contributor Author

@stefansedich stefansedich Jun 18, 2021

Choose a reason for hiding this comment

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

Using the ProxyHeaders handler r.URL.Scheme will be populated if any of the x-forwarded-proto headers are set by the proxy, this ensures things work properly even when Argo is running insecure behind a proxy terminating TLS.

@alexec alexec enabled auto-merge (squash) June 21, 2021 18:25
@alexec alexec merged commit 0e94283 into argoproj:master Jun 22, 2021
@alexec alexec mentioned this pull request Jun 28, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants