Skip to content

Commit e078e8a

Browse files
committed
refactor: move disable ui warnings to ui cfg and trusted proxies to auth
cfg
1 parent a576e91 commit e078e8a

3 files changed

Lines changed: 26 additions & 26 deletions

File tree

.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ TINYAUTH_DATABASEPATH="/data/tinyauth.db"
1010
TINYAUTH_DISABLEANALYTICS="false"
1111
# Disable static resource serving
1212
TINYAUTH_DISABLERESOURCES="false"
13-
# Disable UI warning messages
14-
TINYAUTH_DISABLEUIWARNINGS="false"
1513

1614
# Logging Configuration
1715

@@ -36,8 +34,6 @@ TINYAUTH_SERVER_PORT="3000"
3634
TINYAUTH_SERVER_ADDRESS="0.0.0.0"
3735
# Unix socket path (optional, overrides port/address if set)
3836
TINYAUTH_SERVER_SOCKETPATH=""
39-
# Comma-separated list of trusted proxy IPs/CIDRs
40-
TINYAUTH_SERVER_TRUSTEDPROXIES=""
4137

4238
# Authentication Configuration
4339

@@ -55,6 +51,8 @@ TINYAUTH_AUTH_SESSIONMAXLIFETIME="0"
5551
TINYAUTH_AUTH_LOGINTIMEOUT="300"
5652
# Maximum login retries before lockout
5753
TINYAUTH_AUTH_LOGINMAXRETRIES="5"
54+
# Comma-separated list of trusted proxy IPs/CIDRs
55+
TINYAUTH_AUTH_TRUSTEDPROXIES=""
5856

5957
# OAuth Configuration
6058

@@ -82,6 +80,8 @@ TINYAUTH_UI_TITLE="Tinyauth"
8280
TINYAUTH_UI_FORGOTPASSWORDMESSAGE="Contact your administrator to reset your password"
8381
# Background image URL for login page
8482
TINYAUTH_UI_BACKGROUNDIMAGE=""
83+
# Disable UI warning messages
84+
TINYAUTH_UI_DISABLEWARNINGS="false"
8585

8686
# LDAP Configuration
8787

internal/bootstrap/router_bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ func (app *BootstrapApp) setupRouter() (*gin.Engine, error) {
2121
engine := gin.New()
2222
engine.Use(gin.Recovery())
2323

24-
if len(app.config.Server.TrustedProxies) > 0 {
25-
err := engine.SetTrustedProxies(app.config.Server.TrustedProxies)
24+
if len(app.config.Auth.TrustedProxies) > 0 {
25+
err := engine.SetTrustedProxies(app.config.Auth.TrustedProxies)
2626

2727
if err != nil {
2828
return nil, fmt.Errorf("failed to set trusted proxies: %w", err)
@@ -71,7 +71,7 @@ func (app *BootstrapApp) setupRouter() (*gin.Engine, error) {
7171
ForgotPasswordMessage: app.config.UI.ForgotPasswordMessage,
7272
BackgroundImage: app.config.UI.BackgroundImage,
7373
OAuthAutoRedirect: app.config.OAuth.AutoRedirect,
74-
DisableUIWarnings: app.config.DisableUIWarnings,
74+
DisableUIWarnings: app.config.UI.DisableWarnings,
7575
}, apiRouter)
7676

7777
contextController.SetupRoutes()

internal/config/config.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,26 @@ var RedirectCookieName = "tinyauth-redirect"
1515
// Main app config
1616

1717
type Config struct {
18-
AppURL string `description:"The base URL where the app is hosted." yaml:"appUrl"`
19-
ResourcesDir string `description:"The directory where resources are stored." yaml:"resourcesDir"`
20-
DatabasePath string `description:"The path to the database file." yaml:"databasePath"`
21-
DisableAnalytics bool `description:"Disable analytics." yaml:"disableAnalytics"`
22-
DisableResources bool `description:"Disable resources server." yaml:"disableResources"`
23-
DisableUIWarnings bool `description:"Disable UI warnings." yaml:"disableUIWarnings"`
24-
Server ServerConfig `description:"Server configuration." yaml:"server"`
25-
Auth AuthConfig `description:"Authentication configuration." yaml:"auth"`
26-
Apps map[string]App `description:"Application ACLs configuration." yaml:"apps"`
27-
OAuth OAuthConfig `description:"OAuth configuration." yaml:"oauth"`
28-
OIDC OIDCConfig `description:"OIDC configuration." yaml:"oidc"`
29-
UI UIConfig `description:"UI customization." yaml:"ui"`
30-
Ldap LdapConfig `description:"LDAP configuration." yaml:"ldap"`
31-
Experimental ExperimentalConfig `description:"Experimental features, use with caution." yaml:"experimental"`
32-
Log LogConfig `description:"Logging configuration." yaml:"log"`
18+
AppURL string `description:"The base URL where the app is hosted." yaml:"appUrl"`
19+
ResourcesDir string `description:"The directory where resources are stored." yaml:"resourcesDir"`
20+
DatabasePath string `description:"The path to the database file." yaml:"databasePath"`
21+
DisableAnalytics bool `description:"Disable analytics." yaml:"disableAnalytics"`
22+
DisableResources bool `description:"Disable resources server." yaml:"disableResources"`
23+
Server ServerConfig `description:"Server configuration." yaml:"server"`
24+
Auth AuthConfig `description:"Authentication configuration." yaml:"auth"`
25+
Apps map[string]App `description:"Application ACLs configuration." yaml:"apps"`
26+
OAuth OAuthConfig `description:"OAuth configuration." yaml:"oauth"`
27+
OIDC OIDCConfig `description:"OIDC configuration." yaml:"oidc"`
28+
UI UIConfig `description:"UI customization." yaml:"ui"`
29+
Ldap LdapConfig `description:"LDAP configuration." yaml:"ldap"`
30+
Experimental ExperimentalConfig `description:"Experimental features, use with caution." yaml:"experimental"`
31+
Log LogConfig `description:"Logging configuration." yaml:"log"`
3332
}
3433

3534
type ServerConfig struct {
36-
Port int `description:"The port on which the server listens." yaml:"port"`
37-
Address string `description:"The address on which the server listens." yaml:"address"`
38-
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"`
39-
TrustedProxies []string `description:"Comma-separated list of trusted proxy addresses." yaml:"trustedProxies"`
35+
Port int `description:"The port on which the server listens." yaml:"port"`
36+
Address string `description:"The address on which the server listens." yaml:"address"`
37+
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"`
4038
}
4139

4240
type AuthConfig struct {
@@ -48,6 +46,7 @@ type AuthConfig struct {
4846
SessionMaxLifetime int `description:"Maximum session lifetime in seconds." yaml:"sessionMaxLifetime"`
4947
LoginTimeout int `description:"Login timeout in seconds." yaml:"loginTimeout"`
5048
LoginMaxRetries int `description:"Maximum login retries." yaml:"loginMaxRetries"`
49+
TrustedProxies []string `description:"Comma-separated list of trusted proxy addresses." yaml:"trustedProxies"`
5150
}
5251

5352
type IPConfig struct {
@@ -71,6 +70,7 @@ type UIConfig struct {
7170
Title string `description:"The title of the UI." yaml:"title"`
7271
ForgotPasswordMessage string `description:"Message displayed on the forgot password page." yaml:"forgotPasswordMessage"`
7372
BackgroundImage string `description:"Path to the background image." yaml:"backgroundImage"`
73+
DisableWarnings bool `description:"Disable UI warnings." yaml:"disableWarnings"`
7474
}
7575

7676
type LdapConfig struct {

0 commit comments

Comments
 (0)