mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-16 18:47:10 +02:00
proxy: fix unauthorized redirect loop (fwdauth) (#448)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
8b7f344e01
commit
f0d811f2bb
6 changed files with 38 additions and 53 deletions
|
@ -142,13 +142,13 @@ func (p *Proxy) AuthorizeSession(next http.Handler) http.Handler {
|
|||
func (p *Proxy) authorize(host string, r *http.Request) error {
|
||||
s, err := sessions.FromContext(r.Context())
|
||||
if err != nil {
|
||||
return httputil.NewError(http.StatusUnauthorized, err)
|
||||
return httputil.NewError(http.StatusInternalServerError, err)
|
||||
}
|
||||
authorized, err := p.AuthorizeClient.Authorize(r.Context(), host, s)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !authorized {
|
||||
return httputil.NewError(http.StatusUnauthorized, fmt.Errorf("%s is not authorized for %s", s.RequestEmail(), host))
|
||||
return httputil.NewError(http.StatusForbidden, fmt.Errorf("%s is not authorized for %s", s.RequestEmail(), host))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue