mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-23 08:42:57 +00:00
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.
39 lines
616 B
Go
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()
|
|
}
|