git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #30 from sonatype/master
cfad6acJehiah Czebotar
README.md+1
@@ -110,6 +110,7 @@ The environment variables `google_auth_client_id`, `google_auth_secret` and `goo
110
110
111Google auth proxy responds directly to the following endpoints. All other endpoints will be authenticated.
111Google auth proxy responds directly to the following endpoints. All other endpoints will be authenticated.
112
112
113+* /ping - returns an 200 OK response
113* /oauth2/sign_in - the login page, which also doubles as a sign out page (it clears cookies)
114* /oauth2/sign_in - the login page, which also doubles as a sign out page (it clears cookies)
114* /oauth2/start - a URL that will redirect to start the oauth cycle
115* /oauth2/start - a URL that will redirect to start the oauth cycle
115* /oauth2/callback - the URL used at the end of the oauth cycle
116* /oauth2/callback - the URL used at the end of the oauth cycle
oauthproxy.go+11
@@ -16,6 +16,7 @@ import (
16 "github.com/bitly/go-simplejson"
16 "github.com/bitly/go-simplejson"
17)
17)
18
18
19+const pingPath = "/ping"
19const signInPath = "/oauth2/sign_in"
20const signInPath = "/oauth2/sign_in"
20const oauthStartPath = "/oauth2/start"
21const oauthStartPath = "/oauth2/start"
21const oauthCallbackPath = "/oauth2/callback"
22const oauthCallbackPath = "/oauth2/callback"
@@ -192,6 +193,11 @@ func (p *OauthProxy) SetCookie(rw http.ResponseWriter, req *http.Request, val st
192 http.SetCookie(rw, cookie)
193 http.SetCookie(rw, cookie)
193}
194}
194
195
196+func (p *OauthProxy) PingPage(rw http.ResponseWriter) {
197+ rw.WriteHeader(http.StatusOK)
198+ fmt.Fprintf(rw, "OK")
199+}
200+
195func (p *OauthProxy) ErrorPage(rw http.ResponseWriter, code int, title string, message string) {
201func (p *OauthProxy) ErrorPage(rw http.ResponseWriter, code int, title string, message string) {
196 log.Printf("ErrorPage %d %s %s", code, title, message)
202 log.Printf("ErrorPage %d %s %s", code, title, message)
197 rw.WriteHeader(code)
203 rw.WriteHeader(code)
@@ -267,6 +273,11 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
267 var ok bool
273 var ok bool
268 var user string
274 var user string
269
275
276+ if req.URL.Path == pingPath {
277+ p.PingPage(rw)
278+ return
279+ }
280+
270 if req.URL.Path == signInPath {
281 if req.URL.Path == signInPath {
271 redirect, err := p.GetRedirect(req)
282 redirect, err := p.GetRedirect(req)
272 if err != nil {
283 if err != nil {