AuthOnly checks whether the user is currently logged in (both authentication and optional authorization).
(rw http.ResponseWriter, req *http.Request)
| 1016 | // AuthOnly checks whether the user is currently logged in (both authentication |
| 1017 | // and optional authorization). |
| 1018 | func (p *OAuthProxy) AuthOnly(rw http.ResponseWriter, req *http.Request) { |
| 1019 | session, err := p.getAuthenticatedSession(rw, req) |
| 1020 | if err != nil { |
| 1021 | http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) |
| 1022 | return |
| 1023 | } |
| 1024 | |
| 1025 | // Unauthorized cases need to return 403 to prevent infinite redirects with |
| 1026 | // subrequest architectures |
| 1027 | if !authOnlyAuthorize(req, session) { |
| 1028 | http.Error(rw, http.StatusText(http.StatusForbidden), http.StatusForbidden) |
| 1029 | return |
| 1030 | } |
| 1031 | |
| 1032 | // we are authenticated |
| 1033 | p.addHeadersForProxying(rw, session) |
| 1034 | p.headersChain.Then(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { |
| 1035 | rw.WriteHeader(http.StatusAccepted) |
| 1036 | })).ServeHTTP(rw, req) |
| 1037 | } |
| 1038 | |
| 1039 | // Proxy proxies the user request if the user is authenticated else it prompts |
| 1040 | // them to authenticate |
nothing calls this directly
no test coverage detected