mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 01:10:20 -06:00
incorporate requested changes
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
package staticroutes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/render"
|
||||
"github.com/pkg/errors"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// handle backchannel logout requests as per https://openid.net/specs/openid-connect-backchannel-1_0.html#BCRequest
|
||||
|
||||
@@ -9,13 +9,13 @@ var (
|
||||
wellKnownPath = "/.well-known/openid-configuration"
|
||||
)
|
||||
|
||||
// OIDCWellKnownRewrite is a middleware that rewrites the /.well-known/openid-configuration endpoint for external IDPs.
|
||||
func (s *StaticRouteHandler) OIDCWellKnownRewrite(w http.ResponseWriter, r *http.Request) {
|
||||
// OIDCWellKnownRewrite is a handler that rewrites the /.well-known/openid-configuration endpoint for external IDPs.
|
||||
func (s *StaticRouteHandler) oIDCWellKnownRewrite(w http.ResponseWriter, r *http.Request) {
|
||||
wellKnownRes, err := s.OidcHttpClient.Get(s.oidcURL.String())
|
||||
if err != nil {
|
||||
s.Logger.Error().
|
||||
Err(err).
|
||||
Str("middleware", "oidc wellknown rewrite").
|
||||
Str("handler", "oidc wellknown rewrite").
|
||||
Str("url", s.oidcURL.String()).
|
||||
Msg("get information from url failed")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
@@ -26,9 +26,14 @@ func (s *StaticRouteHandler) OIDCWellKnownRewrite(w http.ResponseWriter, r *http
|
||||
|
||||
copyHeader(w.Header(), wellKnownRes.Header)
|
||||
w.WriteHeader(wellKnownRes.StatusCode)
|
||||
io.Copy(w, wellKnownRes.Body)
|
||||
_, err = io.Copy(w, wellKnownRes.Body)
|
||||
if err != nil {
|
||||
s.Logger.Error().
|
||||
Err(err).
|
||||
Str("handler", "oidc wellknown rewrite").
|
||||
Msg("copying response body failed")
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func copyHeader(dst, src http.Header) {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package staticroutes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/oidc"
|
||||
"github.com/owncloud/ocis/v2/services/proxy/pkg/config"
|
||||
microstore "go-micro.dev/v4/store"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
)
|
||||
|
||||
// StaticRouteHandler defines a Route Handler for static routes
|
||||
@@ -40,9 +41,9 @@ func (s *StaticRouteHandler) Handler() http.Handler {
|
||||
|
||||
// openid .well-known
|
||||
if s.Config.OIDC.RewriteWellKnown {
|
||||
r.Get("/.well-known/openid-configuration", s.OIDCWellKnownRewrite)
|
||||
r.Get("/.well-known/openid-configuration", s.oIDCWellKnownRewrite)
|
||||
}
|
||||
|
||||
|
||||
// Send all requests to the proxy handler
|
||||
r.HandleFunc("/*", s.Proxy.ServeHTTP)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user