outpost/proxy: use common template for proxy error

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-09-07 16:44:15 +02:00
parent de3e1c3dbc
commit bc7d5042df
5 changed files with 93 additions and 16 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/oauth2-proxy/oauth2-proxy/providers"
"goauthentik.io/api"
"goauthentik.io/internal/utils/web"
staticWeb "goauthentik.io/web"
log "github.com/sirupsen/logrus"
)
@ -255,11 +256,18 @@ func (p *OAuthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
p.AuthenticateOnly(rw, req)
case path == p.UserInfoPath:
p.UserInfo(rw, req)
case strings.HasPrefix(path, fmt.Sprintf("%s/static", p.ProxyPrefix)):
p.ServeStatic(rw, req)
default:
p.Proxy(rw, req)
}
}
func (p *OAuthProxy) ServeStatic(rw http.ResponseWriter, req *http.Request) {
staticFs := http.FileServer(http.FS(staticWeb.StaticDist))
http.StripPrefix(fmt.Sprintf("%s/static", p.ProxyPrefix), staticFs).ServeHTTP(rw, req)
}
//UserInfo endpoint outputs session email and preferred username in JSON format
func (p *OAuthProxy) UserInfo(rw http.ResponseWriter, req *http.Request) {