mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 08:19:23 +02:00
config: add branding settings (#3558)
This commit is contained in:
parent
c9421ec146
commit
46703b9419
8 changed files with 156 additions and 13 deletions
35
internal/httputil/branding.go
Normal file
35
internal/httputil/branding.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package httputil
|
||||
|
||||
// The BrandingOptions customize the user info and error pages.
|
||||
type BrandingOptions interface {
|
||||
GetPrimaryColor() string
|
||||
GetSecondaryColor() string
|
||||
GetDarkmodePrimaryColor() string
|
||||
GetDarkmodeSecondaryColor() string
|
||||
GetLogoUrl() string
|
||||
GetFaviconUrl() string
|
||||
GetErrorMessageFirstParagraph() string
|
||||
}
|
||||
|
||||
// AddBrandingOptionsToMap adds the branding options to the map.
|
||||
func AddBrandingOptionsToMap(dst map[string]any, brandingOptions BrandingOptions) {
|
||||
if brandingOptions == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if brandingOptions.GetPrimaryColor() != "" {
|
||||
dst["primaryColor"] = brandingOptions.GetPrimaryColor()
|
||||
}
|
||||
if brandingOptions.GetSecondaryColor() != "" {
|
||||
dst["secondaryColor"] = brandingOptions.GetSecondaryColor()
|
||||
}
|
||||
if brandingOptions.GetLogoUrl() != "" {
|
||||
dst["logoUrl"] = brandingOptions.GetLogoUrl()
|
||||
}
|
||||
if brandingOptions.GetFaviconUrl() != "" {
|
||||
dst["faviconUrl"] = brandingOptions.GetFaviconUrl()
|
||||
}
|
||||
if brandingOptions.GetErrorMessageFirstParagraph() != "" {
|
||||
dst["errorMessageFirstParagraph"] = brandingOptions.GetErrorMessageFirstParagraph()
|
||||
}
|
||||
}
|
|
@ -20,6 +20,8 @@ type HTTPError struct {
|
|||
DebugURL *url.URL
|
||||
// The request ID.
|
||||
RequestID string
|
||||
|
||||
BrandingOptions BrandingOptions
|
||||
}
|
||||
|
||||
// NewError returns an error that contains a HTTP status and error.
|
||||
|
@ -73,7 +75,7 @@ func (e *HTTPError) ErrorResponse(ctx context.Context, w http.ResponseWriter, r
|
|||
return
|
||||
}
|
||||
|
||||
m := map[string]interface{}{
|
||||
m := map[string]any{
|
||||
"canDebug": response.CanDebug,
|
||||
"error": response.Error,
|
||||
"requestId": response.RequestID,
|
||||
|
@ -84,6 +86,7 @@ func (e *HTTPError) ErrorResponse(ctx context.Context, w http.ResponseWriter, r
|
|||
if response.DebugURL != nil {
|
||||
m["debugUrl"] = response.DebugURL.String()
|
||||
}
|
||||
AddBrandingOptionsToMap(m, e.BrandingOptions)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
|
||||
w.WriteHeader(response.Status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue