Files
opencloud/services/proxy/pkg/staticroutes/staticroutes.go
T
zerox80 b945a94532 Merge branch 'main' into codex/oidc-session-logout
main brought the audit log and reva v3. Besides the textual conflicts, some
code of both sides no longer fits together and is adapted here:

- newOIDCAuthenticator and loadMiddlewares take the logout markers and the
  audit emitter.
- The backchannel logout handler still writes the marker first. The logout is
  audited once the user is resolved, whether or not the cached claims can be
  removed afterwards, because the marker has ended the session by then.
- userForClaimKey reads the cached TokenRecord instead of a plain claims map.
- isExpectedTokenTimeError stays, because the audit log uses it to leave out
  expired tokens. A token rejected by a logout marker is still audited as a
  failed login, isExpectedTokenError only keeps it out of the error log.
- The audit test of the handler gets logout markers, an iat in the logout
  token and the new format of the cached record.
- The middleware test of the command package passes no markers.
- The logout tests import the events of reva v3.

Assisted-by: Claude Code:Claude Mythos 5.2
2026-11-30 10:25:52 +00:00

58 lines
1.6 KiB
Go

package staticroutes
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/opencloud-eu/opencloud/pkg/log"
"github.com/opencloud-eu/opencloud/pkg/oidc"
"github.com/opencloud-eu/opencloud/services/proxy/pkg/config"
bcl "github.com/opencloud-eu/opencloud/services/proxy/pkg/staticroutes/backchannellogout"
"github.com/opencloud-eu/opencloud/services/proxy/pkg/user/backend"
"github.com/opencloud-eu/reva/v3/pkg/audit"
"github.com/opencloud-eu/reva/v3/pkg/events"
microstore "go-micro.dev/v4/store"
)
// StaticRouteHandler defines a Route Handler for static routes
type StaticRouteHandler struct {
Prefix string
Proxy http.Handler
UserInfoCache microstore.Store
LogoutMarkers *bcl.LogoutMarkers
Logger log.Logger
Config config.Config
OidcClient oidc.OIDCClient
OidcHttpClient *http.Client
EventsPublisher events.Publisher
AuditEmitter audit.Emitter
UserProvider backend.UserBackend
}
type jse struct {
Error string `json:"error"`
ErrorDescription string `json:"error_description"`
}
func (s *StaticRouteHandler) Handler() http.Handler {
m := chi.NewMux()
m.Route(s.Prefix, func(r chi.Router) {
// Wrapper for backchannel logout
r.Post("/backchannel_logout", s.backchannelLogout)
// openid .well-known
if s.Config.OIDC.RewriteWellKnown {
r.Get("/.well-known/openid-configuration", s.oIDCWellKnownRewrite(s.Config.OIDC.Issuer))
}
// Send all requests to the proxy handler
r.HandleFunc("/*", s.Proxy.ServeHTTP)
})
// Also send requests for methods unknown to chi to the proxy handler as well
m.MethodNotAllowed(s.Proxy.ServeHTTP)
return m
}