Files
wonderwall/pkg/openid/client/logout_callback.go
Trong Huu Nguyen 5a50ba7c3a feat: support multiple ingresses
Replace hardcoded callback URLs with dynamic generation
of URLs based on incoming requests. These are validated against
a pre-registered list of ingresses for which Wonderwall is considered
authorative for.

We also preserve the cookie behaviour; the most specific ingress path
and domain is used for the cookies.

The `url` package has been moved to the `handler` package, and its
implementation refactored slightly for readability and DRY.
2022-08-17 20:43:56 +02:00

39 lines
616 B
Go

package client
import (
"net/http"
mw "github.com/nais/wonderwall/pkg/middleware"
)
type LogoutCallback interface {
PostLogoutRedirectURI() string
}
type logoutCallback struct {
Client
request *http.Request
}
func NewLogoutCallback(c Client, r *http.Request) LogoutCallback {
return &logoutCallback{
Client: c,
request: r,
}
}
func (in *logoutCallback) PostLogoutRedirectURI() string {
redirect := in.config().Client().PostLogoutRedirectURI()
if len(redirect) > 0 {
return redirect
}
ingress, ok := mw.IngressFrom(in.request.Context())
if !ok {
return "/"
}
return ingress.String()
}