Skip to content

Commit 6112f97

Browse files
authored
feat: auto generate example env file (#647)
* feat: auto generate example env file * refactor: simplify build paths func and better slice handling * chore: forgot to stage everything * chore: review comments * refactor: remove square brackets because they mess up the syntax highlighting * refactor: use lowercase name to mark dynamic values
1 parent e078e8a commit 6112f97

6 files changed

Lines changed: 427 additions & 152 deletions

File tree

.env.example

Lines changed: 219 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,221 @@
1-
# Base Configuration
2-
3-
# The base URL where Tinyauth is accessible
4-
TINYAUTH_APPURL="https://auth.example.com"
5-
# Directory for static resources
6-
TINYAUTH_RESOURCESDIR="/data/resources"
7-
# Path to SQLite database file
8-
TINYAUTH_DATABASEPATH="/data/tinyauth.db"
9-
# Disable version heartbeat
10-
TINYAUTH_DISABLEANALYTICS="false"
11-
# Disable static resource serving
12-
TINYAUTH_DISABLERESOURCES="false"
13-
14-
# Logging Configuration
15-
16-
# Log level: trace, debug, info, warn, error
17-
TINYAUTH_LOG_LEVEL="info"
18-
# Enable JSON formatted logs
19-
TINYAUTH_LOG_JSON="false"
20-
# Specific Log stream configurations
21-
# APP and HTTP log streams are enabled by default, and use the global log level unless overridden
22-
TINYAUTH_LOG_STREAMS_APP_ENABLED="true"
23-
TINYAUTH_LOG_STREAMS_APP_LEVEL="info"
24-
TINYAUTH_LOG_STREAMS_HTTP_ENABLED="true"
25-
TINYAUTH_LOG_STREAMS_HTTP_LEVEL="info"
26-
TINYAUTH_LOG_STREAMS_AUDIT_ENABLED="false"
27-
TINYAUTH_LOG_STREAMS_AUDIT_LEVEL="info"
28-
29-
# Server Configuration
30-
31-
# Port to listen on
32-
TINYAUTH_SERVER_PORT="3000"
33-
# Interface to bind to (0.0.0.0 for all interfaces)
1+
# Tinyauth example configuration
2+
3+
# The base URL where the app is hosted.
4+
TINYAUTH_APPURL=
5+
6+
# The directory where resources are stored.
7+
TINYAUTH_RESOURCESDIR="./resources"
8+
9+
# The path to the database file.
10+
TINYAUTH_DATABASEPATH="./tinyauth.db"
11+
12+
# Disable analytics.
13+
TINYAUTH_DISABLEANALYTICS=false
14+
15+
# Disable resources server.
16+
TINYAUTH_DISABLERESOURCES=false
17+
18+
# The port on which the server listens.
19+
TINYAUTH_SERVER_PORT=3000
20+
21+
# The address on which the server listens.
3422
TINYAUTH_SERVER_ADDRESS="0.0.0.0"
35-
# Unix socket path (optional, overrides port/address if set)
36-
TINYAUTH_SERVER_SOCKETPATH=""
37-
38-
# Authentication Configuration
39-
40-
# Format: username:bcrypt_hash (use bcrypt to generate hash)
41-
TINYAUTH_AUTH_USERS="admin:$2a$10$example_bcrypt_hash_here"
42-
# Path to external users file (optional)
43-
TINYAUTH_AUTH_USERSFILE=""
44-
# Enable secure cookies (requires HTTPS)
45-
TINYAUTH_AUTH_SECURECOOKIE="true"
46-
# Session expiry in seconds (7200 = 2 hours)
47-
TINYAUTH_AUTH_SESSIONEXPIRY="7200"
48-
# Session maximum lifetime in seconds (0 = unlimited)
49-
TINYAUTH_AUTH_SESSIONMAXLIFETIME="0"
50-
# Login timeout in seconds (300 = 5 minutes)
51-
TINYAUTH_AUTH_LOGINTIMEOUT="300"
52-
# Maximum login retries before lockout
53-
TINYAUTH_AUTH_LOGINMAXRETRIES="5"
54-
# Comma-separated list of trusted proxy IPs/CIDRs
55-
TINYAUTH_AUTH_TRUSTEDPROXIES=""
56-
57-
# OAuth Configuration
58-
59-
# Regex pattern for allowed email addresses (e.g., /@example\.com$/)
60-
TINYAUTH_OAUTH_WHITELIST=""
61-
# Provider ID to auto-redirect to (skips login page)
62-
TINYAUTH_OAUTH_AUTOREDIRECT=""
63-
# OAuth Provider Configuration (replace MYPROVIDER with your provider name)
64-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_CLIENTID="your_client_id_here"
65-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_CLIENTSECRET="your_client_secret_here"
66-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_AUTHURL="https://provider.example.com/oauth/authorize"
67-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_TOKENURL="https://provider.example.com/oauth/token"
68-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_USERINFOURL="https://provider.example.com/oauth/userinfo"
69-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_REDIRECTURL="https://auth.example.com/oauth/callback/myprovider"
70-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_SCOPES="openid email profile"
71-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_NAME="My OAuth Provider"
72-
# Allow self-signed certificates
73-
TINYAUTH_OAUTH_PROVIDERS_MYPROVIDER_INSECURE="false"
74-
75-
# UI Customization
76-
77-
# Custom title for login page
23+
24+
# The path to the Unix socket.
25+
TINYAUTH_SERVER_SOCKETPATH=
26+
27+
# List of allowed IPs or CIDR ranges.
28+
TINYAUTH_AUTH_IP_ALLOW=
29+
30+
# List of blocked IPs or CIDR ranges.
31+
TINYAUTH_AUTH_IP_BLOCK=
32+
33+
# Comma-separated list of users (username:hashed_password).
34+
TINYAUTH_AUTH_USERS=
35+
36+
# Path to the users file.
37+
TINYAUTH_AUTH_USERSFILE=
38+
39+
# Enable secure cookies.
40+
TINYAUTH_AUTH_SECURECOOKIE=false
41+
42+
# Session expiry time in seconds.
43+
TINYAUTH_AUTH_SESSIONEXPIRY=86400
44+
45+
# Maximum session lifetime in seconds.
46+
TINYAUTH_AUTH_SESSIONMAXLIFETIME=0
47+
48+
# Login timeout in seconds.
49+
TINYAUTH_AUTH_LOGINTIMEOUT=300
50+
51+
# Maximum login retries.
52+
TINYAUTH_AUTH_LOGINMAXRETRIES=3
53+
54+
# Comma-separated list of trusted proxy addresses.
55+
TINYAUTH_AUTH_TRUSTEDPROXIES=
56+
57+
# The domain of the app.
58+
TINYAUTH_APPS_name_CONFIG_DOMAIN=
59+
60+
# Comma-separated list of allowed users.
61+
TINYAUTH_APPS_name_USERS_ALLOW=
62+
63+
# Comma-separated list of blocked users.
64+
TINYAUTH_APPS_name_USERS_BLOCK=
65+
66+
# Comma-separated list of allowed OAuth groups.
67+
TINYAUTH_APPS_name_OAUTH_WHITELIST=
68+
69+
# Comma-separated list of required OAuth groups.
70+
TINYAUTH_APPS_name_OAUTH_GROUPS=
71+
72+
# List of allowed IPs or CIDR ranges.
73+
TINYAUTH_APPS_name_IP_ALLOW=
74+
75+
# List of blocked IPs or CIDR ranges.
76+
TINYAUTH_APPS_name_IP_BLOCK=
77+
78+
# List of IPs or CIDR ranges that bypass authentication.
79+
TINYAUTH_APPS_name_IP_BYPASS=
80+
81+
# Custom headers to add to the response.
82+
TINYAUTH_APPS_name_RESPONSE_HEADERS=
83+
84+
# Basic auth username.
85+
TINYAUTH_APPS_name_RESPONSE_BASICAUTH_USERNAME=
86+
87+
# Basic auth password.
88+
TINYAUTH_APPS_name_RESPONSE_BASICAUTH_PASSWORD=
89+
90+
# Path to the file containing the basic auth password.
91+
TINYAUTH_APPS_name_RESPONSE_BASICAUTH_PASSWORDFILE=
92+
93+
# Comma-separated list of allowed paths.
94+
TINYAUTH_APPS_name_PATH_ALLOW=
95+
96+
# Comma-separated list of blocked paths.
97+
TINYAUTH_APPS_name_PATH_BLOCK=
98+
99+
# Comma-separated list of required LDAP groups.
100+
TINYAUTH_APPS_name_LDAP_GROUPS=
101+
102+
# Comma-separated list of allowed OAuth domains.
103+
TINYAUTH_OAUTH_WHITELIST=
104+
105+
# The OAuth provider to use for automatic redirection.
106+
TINYAUTH_OAUTH_AUTOREDIRECT=
107+
108+
# OAuth client ID.
109+
TINYAUTH_OAUTH_PROVIDERS_name_CLIENTID=
110+
111+
# OAuth client secret.
112+
TINYAUTH_OAUTH_PROVIDERS_name_CLIENTSECRET=
113+
114+
# Path to the file containing the OAuth client secret.
115+
TINYAUTH_OAUTH_PROVIDERS_name_CLIENTSECRETFILE=
116+
117+
# OAuth scopes.
118+
TINYAUTH_OAUTH_PROVIDERS_name_SCOPES=
119+
120+
# OAuth redirect URL.
121+
TINYAUTH_OAUTH_PROVIDERS_name_REDIRECTURL=
122+
123+
# OAuth authorization URL.
124+
TINYAUTH_OAUTH_PROVIDERS_name_AUTHURL=
125+
126+
# OAuth token URL.
127+
TINYAUTH_OAUTH_PROVIDERS_name_TOKENURL=
128+
129+
# OAuth userinfo URL.
130+
TINYAUTH_OAUTH_PROVIDERS_name_USERINFOURL=
131+
132+
# Allow insecure OAuth connections.
133+
TINYAUTH_OAUTH_PROVIDERS_name_INSECURE=false
134+
135+
# Provider name in UI.
136+
TINYAUTH_OAUTH_PROVIDERS_name_NAME=
137+
138+
# Path to the private key file.
139+
TINYAUTH_OIDC_PRIVATEKEYPATH="./tinyauth_oidc_key"
140+
141+
# Path to the public key file.
142+
TINYAUTH_OIDC_PUBLICKEYPATH="./tinyauth_oidc_key.pub"
143+
144+
# OIDC client ID.
145+
TINYAUTH_OIDC_CLIENTS_name_CLIENTID=
146+
147+
# OIDC client secret.
148+
TINYAUTH_OIDC_CLIENTS_name_CLIENTSECRET=
149+
150+
# Path to the file containing the OIDC client secret.
151+
TINYAUTH_OIDC_CLIENTS_name_CLIENTSECRETFILE=
152+
153+
# List of trusted redirect URIs.
154+
TINYAUTH_OIDC_CLIENTS_name_TRUSTEDREDIRECTURIS=
155+
156+
# Client name in UI.
157+
TINYAUTH_OIDC_CLIENTS_name_NAME=
158+
159+
# The title of the UI.
78160
TINYAUTH_UI_TITLE="Tinyauth"
79-
# Message shown on forgot password page
80-
TINYAUTH_UI_FORGOTPASSWORDMESSAGE="Contact your administrator to reset your password"
81-
# Background image URL for login page
82-
TINYAUTH_UI_BACKGROUNDIMAGE=""
83-
# Disable UI warning messages
84-
TINYAUTH_UI_DISABLEWARNINGS="false"
85-
86-
# LDAP Configuration
87-
88-
# LDAP server address
89-
TINYAUTH_LDAP_ADDRESS="ldap://ldap.example.com:389"
90-
# DN for binding to LDAP server
91-
TINYAUTH_LDAP_BINDDN="cn=readonly,dc=example,dc=com"
92-
# Password for bind DN
93-
TINYAUTH_LDAP_BINDPASSWORD="your_bind_password"
94-
# Base DN for user searches
95-
TINYAUTH_LDAP_BASEDN="dc=example,dc=com"
96-
# Search filter (%s will be replaced with username)
97-
TINYAUTH_LDAP_SEARCHFILTER="(&(uid=%s)(memberOf=cn=users,ou=groups,dc=example,dc=com))"
98-
# Allow insecure LDAP connections
99-
TINYAUTH_LDAP_INSECURE="false"
161+
162+
# Message displayed on the forgot password page.
163+
TINYAUTH_UI_FORGOTPASSWORDMESSAGE="You can change your password by changing the configuration."
164+
165+
# Path to the background image.
166+
TINYAUTH_UI_BACKGROUNDIMAGE="/background.jpg"
167+
168+
# Disable UI warnings.
169+
TINYAUTH_UI_DISABLEWARNINGS=false
170+
171+
# LDAP server address.
172+
TINYAUTH_LDAP_ADDRESS=
173+
174+
# Bind DN for LDAP authentication.
175+
TINYAUTH_LDAP_BINDDN=
176+
177+
# Bind password for LDAP authentication.
178+
TINYAUTH_LDAP_BINDPASSWORD=
179+
180+
# Base DN for LDAP searches.
181+
TINYAUTH_LDAP_BASEDN=
182+
183+
# Allow insecure LDAP connections.
184+
TINYAUTH_LDAP_INSECURE=false
185+
186+
# LDAP search filter.
187+
TINYAUTH_LDAP_SEARCHFILTER="(uid=%s)"
188+
189+
# Certificate for mTLS authentication.
190+
TINYAUTH_LDAP_AUTHCERT=
191+
192+
# Certificate key for mTLS authentication.
193+
TINYAUTH_LDAP_AUTHKEY=
194+
195+
# Cache duration for LDAP group membership in seconds.
196+
TINYAUTH_LDAP_GROUPCACHETTL=900
197+
198+
# Log level (trace, debug, info, warn, error).
199+
TINYAUTH_LOG_LEVEL="info"
200+
201+
# Enable JSON formatted logs.
202+
TINYAUTH_LOG_JSON=false
203+
204+
# Enable this log stream.
205+
TINYAUTH_LOG_STREAMS_HTTP_ENABLED=true
206+
207+
# Log level for this stream. Use global if empty.
208+
TINYAUTH_LOG_STREAMS_HTTP_LEVEL=
209+
210+
# Enable this log stream.
211+
TINYAUTH_LOG_STREAMS_APP_ENABLED=true
212+
213+
# Log level for this stream. Use global if empty.
214+
TINYAUTH_LOG_STREAMS_APP_LEVEL=
215+
216+
# Enable this log stream.
217+
TINYAUTH_LOG_STREAMS_AUDIT_ENABLED=false
218+
219+
# Log level for this stream. Use global if empty.
220+
TINYAUTH_LOG_STREAMS_AUDIT_LEVEL=
221+

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ test:
6060
go test -v ./...
6161

6262
# Development
63-
develop:
63+
dev:
6464
docker compose -f $(DEV_COMPOSE) up --force-recreate --pull=always --remove-orphans --build
6565

6666
# Development - Infisical
67-
develop-infisical:
67+
dev-infisical:
6868
infisical run --env=dev -- docker compose -f $(DEV_COMPOSE) up --force-recreate --pull=always --remove-orphans --build
6969

7070
# Production
@@ -79,3 +79,7 @@ prod-infisical:
7979
.PHONY: sql
8080
sql:
8181
sqlc generate
82+
83+
# Go gen
84+
generate:
85+
go run ./gen

0 commit comments

Comments
 (0)