2020-07-04 18:41:58 +01:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/justinas/alice"
|
2020-09-30 01:44:42 +09:00
|
|
|
middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
|
2020-07-04 18:41:58 +01:00
|
|
|
)
|
|
|
|
|
2021-01-02 13:16:01 -08:00
|
|
|
func NewScope(reverseProxy bool) alice.Constructor {
|
2020-12-23 17:42:02 -08:00
|
|
|
return func(next http.Handler) http.Handler {
|
|
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
|
|
|
scope := &middlewareapi.RequestScope{
|
2021-01-02 13:16:01 -08:00
|
|
|
ReverseProxy: reverseProxy,
|
2020-12-23 17:42:02 -08:00
|
|
|
}
|
2021-01-02 13:16:01 -08:00
|
|
|
req = middlewareapi.AddRequestScope(req, scope)
|
|
|
|
next.ServeHTTP(rw, req)
|
2020-12-23 17:42:02 -08:00
|
|
|
})
|
|
|
|
}
|
2020-07-04 18:41:58 +01:00
|
|
|
}
|