mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-09 18:06:42 +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.
20 lines
493 B
Go
20 lines
493 B
Go
package mock
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
|
|
mw "github.com/nais/wonderwall/pkg/middleware"
|
|
openidconfig "github.com/nais/wonderwall/pkg/openid/config"
|
|
)
|
|
|
|
func NewGetRequest(target string, openidConfig openidconfig.Config) *http.Request {
|
|
req := httptest.NewRequest(http.MethodGet, target, nil)
|
|
match, ok := openidConfig.Client().Ingresses().MatchingIngress(req)
|
|
if ok {
|
|
req = mw.RequestWithIngress(req, match)
|
|
req = mw.RequestWithPath(req, match.Path())
|
|
}
|
|
return req
|
|
}
|