Skip to content

Commit

Permalink
Quit if oauth2_proxy doesn't return cookie
Browse files Browse the repository at this point in the history
Better to tell users about the problem than just doing nothing.
  • Loading branch information
mfrister committed Jul 17, 2018
1 parent 15c30af commit 269ac3f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,20 @@ func authenticate(upstreamURL *url.URL, authCompleteNotice string) *http.Cookie
return
}

var authCookie *http.Cookie
for _, c := range resp.Cookies() {
if c.Name == "_oauth2_proxy" {
w.Write([]byte(authCompleteNotice + "You can close this window."))
authCookieCh <- c
authCookie = c
break
}
}
if authCookie == nil {
log.Printf("Response from oauth2_proxy:%v\n\n", resp)
log.Fatalf("Error: Expected _oauth2_proxy cookie not found in response " +
"from oauth2_proxy. Please restart the dev proxy and try again.")
}
authCookieCh <- authCookie
})

server := &http.Server{
Expand Down

0 comments on commit 269ac3f

Please sign in to comment.