Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ TINYAUTH_UI_FORGOTPASSWORDMESSAGE="You can change your password by changing the
TINYAUTH_UI_BACKGROUNDIMAGE="/background.webp"
# Value of the CSS background property, takes precedence over the background image.
TINYAUTH_UI_BACKGROUNDCSS=
# Path to the favicon.
TINYAUTH_UI_FAVICON=
# Enable UI warnings.
TINYAUTH_UI_WARNINGSENABLED=true

Expand Down
14 changes: 14 additions & 0 deletions frontend/src/components/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const BaseLayout = ({ children }: { children: React.ReactNode }) => {
document.title = ui.title;
}, [ui.title]);

useEffect(() => {
if (!ui.favicon) return;
document
.querySelectorAll<HTMLLinkElement>(
'link[rel~="icon"], link[rel="apple-touch-icon"]',
)
.forEach((link) => {
link.href = ui.favicon;
// Drop hints to avoid the image being ignored
link.removeAttribute("type");
link.removeAttribute("sizes");
});
}, [ui.favicon]);

return (
<div
className="flex flex-col justify-center items-center min-h-svh px-4"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/schemas/app-context-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const uiSchema = z.object({
forgotPasswordMessage: z.string(),
backgroundImage: z.string(),
backgroundCss: z.string(),
favicon: z.string(),
warningsEnabled: z.boolean(),
});

Expand Down
2 changes: 2 additions & 0 deletions internal/controller/context_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type ACRUI struct {
ForgotPasswordMessage string `json:"forgotPasswordMessage"`
BackgroundImage string `json:"backgroundImage"`
BackgroundCSS string `json:"backgroundCss"`
Favicon string `json:"favicon"`
WarningsEnabled bool `json:"warningsEnabled"`
}

Expand Down Expand Up @@ -163,6 +164,7 @@ func (controller *ContextController) appContextHandler(c *gin.Context) {
ForgotPasswordMessage: controller.config.UI.ForgotPasswordMessage,
BackgroundImage: controller.config.UI.BackgroundImage,
BackgroundCSS: controller.config.UI.BackgroundCSS,
Favicon: controller.config.UI.Favicon,
WarningsEnabled: controller.config.UI.WarningsEnabled,
},
App: ACRApp{
Expand Down
1 change: 1 addition & 0 deletions internal/controller/context_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestContextController(t *testing.T) {
ForgotPasswordMessage: cfg.UI.ForgotPasswordMessage,
BackgroundImage: cfg.UI.BackgroundImage,
BackgroundCSS: cfg.UI.BackgroundCSS,
Favicon: cfg.UI.Favicon,
WarningsEnabled: cfg.UI.WarningsEnabled,
},
App: ACRApp{
Expand Down
1 change: 1 addition & 0 deletions internal/model/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ type UIConfig struct {
ForgotPasswordMessage string `description:"Message displayed on the forgot password page." yaml:"forgotPasswordMessage,omitempty"`
BackgroundImage string `description:"Path to the background image." yaml:"backgroundImage,omitempty"`
BackgroundCSS string `description:"Value of the CSS background property, takes precedence over the background image." yaml:"backgroundCss,omitempty"`
Favicon string `description:"Path to the favicon." yaml:"favicon,omitempty"`
WarningsEnabled bool `description:"Enable UI warnings." yaml:"warningsEnabled,omitempty"`
}

Expand Down
1 change: 1 addition & 0 deletions internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func CreateTestConfigs(t *testing.T) (model.Config, model.RuntimeConfig) {
Title: "Tinyauth Test",
ForgotPasswordMessage: "foo",
BackgroundImage: "/background.webp",
Favicon: "https://example.com/favicon.png",
WarningsEnabled: true,
},
OAuth: model.OAuthConfig{
Expand Down