mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-08 17:37:01 +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.
28 lines
776 B
Go
28 lines
776 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/nais/wonderwall/pkg/session"
|
|
)
|
|
|
|
func (h *Handler) SetSessionFallback(w http.ResponseWriter, r *http.Request, data *session.Data, expiresIn time.Duration) error {
|
|
store := h.cookieStore(w, r)
|
|
return store.Write(data, expiresIn)
|
|
}
|
|
|
|
func (h *Handler) GetSessionFallback(w http.ResponseWriter, r *http.Request) (*session.Data, error) {
|
|
store := h.cookieStore(w, r)
|
|
return store.Read(r.Context())
|
|
}
|
|
|
|
func (h *Handler) DeleteSessionFallback(w http.ResponseWriter, r *http.Request) {
|
|
store := h.cookieStore(w, r)
|
|
store.Delete()
|
|
}
|
|
|
|
func (h *Handler) cookieStore(w http.ResponseWriter, r *http.Request) session.CookieStore {
|
|
return session.NewCookie(w, r, h.Crypter, h.Provider, h.CookieOptions.WithPath(h.Path(r)))
|
|
}
|