pomerium/internal/handlers/signedout.go
Kenneth Jenkins e8edb465f4
authenticate: apply branding to sign out pages (#5044)
Add support for the Enterprise branding options to the sign_out and
signed_out page handlers.
2024-04-01 11:32:29 -07:00

33 lines
927 B
Go

package handlers
import (
"net/http"
"github.com/pomerium/pomerium/internal/httputil"
"github.com/pomerium/pomerium/ui"
)
// SignedOutData is the data for the SignedOut page.
type SignedOutData struct {
BrandingOptions httputil.BrandingOptions
}
// ToJSON converts the data into a JSON map.
func (data SignedOutData) ToJSON() map[string]interface{} {
m := map[string]interface{}{}
httputil.AddBrandingOptionsToMap(m, data.BrandingOptions)
return m
}
// SignedOut returns a handler that renders the signed out page.
func SignedOut(data SignedOutData) http.Handler {
return httputil.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
if redirectURI, ok := httputil.GetSignedOutRedirectURICookie(w, r); ok {
httputil.Redirect(w, r, redirectURI, http.StatusFound)
return nil
}
// otherwise show the signed-out page
return ui.ServePage(w, r, "SignedOut", "Signed Out", data.ToJSON())
})
}