Skip to content

feat: auto generate example env file#647

Merged
steveiliop56 merged 6 commits into
mainfrom
feat/env-auto-gen
Feb 16, 2026
Merged

feat: auto generate example env file#647
steveiliop56 merged 6 commits into
mainfrom
feat/env-auto-gen

Conversation

@steveiliop56
Copy link
Copy Markdown
Member

@steveiliop56 steveiliop56 commented Feb 16, 2026

Summary by CodeRabbit

  • Chores
    • Replaced verbose example env settings with a minimal, templated default configuration.
    • Normalized core defaults (ports, addresses, timeouts, booleans) and simplified logging defaults.
    • Reorganized auth/OAuth/OIDC and app settings into a generic, name-based structure and neutralized LDAP examples.
    • Updated UI defaults (title, messages, background) for consistency.
    • Renamed developer Makefile targets and added a new generate step.
    • Centralized default configuration creation and exposed build/metadata values for runtime visibility.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 16, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Centralizes runtime defaults into a new config factory, replaces concrete .env.example with a templated NAME-based schema, removes a command-specific defaults constructor, renames Makefile dev targets and adds a generate target, and introduces public build/session metadata variables.

Changes

Cohort / File(s) Summary
Config factory & metadata
cmd/tinyauth/tinyauth.go, internal/config/config.go
Removed NewTinyauthCmdConfiguration() and call sites; added NewDefaultConfiguration() to provide centralized default config. Introduced public metadata vars: CommitHash, BuildTimestamp, SessionCookieName, CSRFCookieName, RedirectCookieName.
Environment example
.env.example
Replaced many concrete example keys/values with a templated, NAME-based defaults layout (apps, OAuth/OIDC, UI, LDAP). Replaced specific URLs/paths/credentials with placeholders and normalized server, logging, and auth defaults.
Build targets / tooling
Makefile
Renamed phony targets (developdev, develop-infisicaldev-infisical) and added generate target (go run ./gen). Build/test/prod flows otherwise preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nudged the defaults, made templates neat,
Keys hop in rows with tidy little feet,
Make targets trimmed and a generator’s tune,
Config burrowed snug beneath the moon 🌙

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: auto generate example env file' accurately describes the main change: introducing infrastructure to automatically generate the .env.example file through a new 'generate' Makefile target and NewDefaultConfiguration() function.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/env-auto-gen

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 0% with 134 lines in your changes missing coverage. Please review.
✅ Project coverage is 15.96%. Comparing base (e078e8a) to head (8e3f10b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
gen/gen_env.go 0.00% 81 Missing ⚠️
internal/config/config.go 0.00% 49 Missing ⚠️
gen/gen.go 0.00% 3 Missing ⚠️
cmd/tinyauth/tinyauth.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #647      +/-   ##
==========================================
- Coverage   16.35%   15.96%   -0.40%     
==========================================
  Files          45       48       +3     
  Lines        3431     3515      +84     
==========================================
  Hits          561      561              
- Misses       2813     2897      +84     
  Partials       57       57              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.


In @.env.example:
- Around line 111-112: The TINYAUTH_UI_FORGOTPASSWORDMESSAGE value contains
spaces and should be quoted in the example file; update the .env.example entry
for TINYAUTH_UI_FORGOTPASSWORDMESSAGE to wrap the multi-word string in quotes
(e.g., "You can change your password by changing the configuration.") so .env
parsers correctly treat it as a single value.
- Around line 97-100: The .env.example has duplicate comments for the OIDC
client fields because the struct tag comment for OIDCClientConfig.ID is
incorrect; update the comment on the ID field of the OIDCClientConfig struct
(symbol: OIDCClientConfig.ID) to a distinct description (e.g., "internal client
identifier / key used by the app") so it differs from
OIDCClientConfig.ClientID's "OAuth client ID", then regenerate the .env.example
so the two lines show unique descriptions.

In `@internal/config/config.go`:
- Around line 64-66: Change the three package-level mutable string variables
SessionCookieName, CSRFCookieName, and RedirectCookieName in config.go to
immutable constants by replacing their var declarations with const declarations
(e.g., const SessionCookieName = "tinyauth-session"); ensure no code elsewhere
relies on taking their address or reassigning them, and run go build/tests to
verify there are no references that require them to be variables.

In `@Makefile`:
- Around line 83-85: Add the non-file targets to the Makefile's .PHONY
declaration so make won't treat same-named files as up-to-date; update the
.PHONY line to include generate (and other non-file targets mentioned such as
dev and dev-infisical) so targets like generate, dev, and dev-infisical always
run regardless of filesystem entries.
🧹 Nitpick comments (2)
🤖 Fix all nitpicks with AI agents
Verify each finding against the current code and only fix it if needed.


In `@internal/config/config.go`:
- Around line 64-66: Change the three package-level mutable string variables
SessionCookieName, CSRFCookieName, and RedirectCookieName in config.go to
immutable constants by replacing their var declarations with const declarations
(e.g., const SessionCookieName = "tinyauth-session"); ensure no code elsewhere
relies on taking their address or reassigning them, and run go build/tests to
verify there are no references that require them to be variables.

In `@Makefile`:
- Around line 83-85: Add the non-file targets to the Makefile's .PHONY
declaration so make won't treat same-named files as up-to-date; update the
.PHONY line to include generate (and other non-file targets mentioned such as
dev and dev-infisical) so targets like generate, dev, and dev-infisical always
run regardless of filesystem entries.
Makefile (1)

83-85: Add generate to .PHONY.

Without a .PHONY declaration, if a file or directory named generate exists in the repo root, make generate will silently no-op. Same applies to other non-file targets like dev and dev-infisical.

Proposed fix
+.PHONY: generate
 # Go gen
 generate:
 	go run ./gen
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 83 - 85, Add the non-file targets to the Makefile's
.PHONY declaration so make won't treat same-named files as up-to-date; update
the .PHONY line to include generate (and other non-file targets mentioned such
as dev and dev-infisical) so targets like generate, dev, and dev-infisical
always run regardless of filesystem entries.
internal/config/config.go (1)

64-66: Convert cookie name variables to const.

These values are not set via -ldflags, never reassigned, and serve only as immutable template values for generating runtime cookie names. Using const prevents accidental mutation and aligns with Go best practices for fixed values.

Proposed fix
-var SessionCookieName = "tinyauth-session"
-var CSRFCookieName = "tinyauth-csrf"
-var RedirectCookieName = "tinyauth-redirect"
+const SessionCookieName = "tinyauth-session"
+const CSRFCookieName = "tinyauth-csrf"
+const RedirectCookieName = "tinyauth-redirect"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/config/config.go` around lines 64 - 66, Change the three
package-level mutable string variables SessionCookieName, CSRFCookieName, and
RedirectCookieName in config.go to immutable constants by replacing their var
declarations with const declarations (e.g., const SessionCookieName =
"tinyauth-session"); ensure no code elsewhere relies on taking their address or
reassigning them, and run go build/tests to verify there are no references that
require them to be variables.

Comment thread .env.example Outdated
Comment thread .env.example Outdated
Comment thread gen/gen_env.go Outdated
Comment thread gen/gen_env.go
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.


In @.env.example:
- Around line 94-96: Update the example OIDC key paths to the project's
recommended defaults by replacing the values for TINYAUTH_OIDC_PRIVATEKEYPATH
and TINYAUTH_OIDC_PUBLICKEYPATH with data/oidc-private.key and
data/oidc-public.key respectively, and also update whatever env/file-generator
logic produces these defaults so new projects get those same paths by default.
🧹 Nitpick comments (1)
🤖 Fix all nitpicks with AI agents
Verify each finding against the current code and only fix it if needed.


In @.env.example:
- Around line 94-96: Update the example OIDC key paths to the project's
recommended defaults by replacing the values for TINYAUTH_OIDC_PRIVATEKEYPATH
and TINYAUTH_OIDC_PUBLICKEYPATH with data/oidc-private.key and
data/oidc-public.key respectively, and also update whatever env/file-generator
logic produces these defaults so new projects get those same paths by default.
.env.example (1)

94-96: Align OIDC key paths with project defaults.

The example paths (./tinyauth_oidc_key and ./tinyauth_oidc_key.pub) differ from the project's recommended defaults. Based on learnings, the OIDC service should use data/oidc-private.key and data/oidc-public.key as default paths.

Consider updating the generator to use:

-TINYAUTH_OIDC_PRIVATEKEYPATH=./tinyauth_oidc_key
+TINYAUTH_OIDC_PRIVATEKEYPATH=data/oidc-private.key
-TINYAUTH_OIDC_PUBLICKEYPATH=./tinyauth_oidc_key.pub
+TINYAUTH_OIDC_PUBLICKEYPATH=data/oidc-public.key
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example around lines 94 - 96, Update the example OIDC key paths to the
project's recommended defaults by replacing the values for
TINYAUTH_OIDC_PRIVATEKEYPATH and TINYAUTH_OIDC_PUBLICKEYPATH with
data/oidc-private.key and data/oidc-public.key respectively, and also update
whatever env/file-generator logic produces these defaults so new projects get
those same paths by default.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.


In @.env.example:
- Around line 138-142: Update the OIDC key path defaults in the environment
example: replace TINYAUTH_OIDC_PRIVATEKEYPATH and TINYAUTH_OIDC_PUBLICKEYPATH
values to use the project-standard paths ("data/oidc-private.key" and
"data/oidc-public.key") so the example matches the required defaults and avoids
misconfiguration; ensure any initialization logic that relies on these env vars
(e.g., OIDC service bootstrap) expects the keys at these default locations.

Comment thread .env.example
@steveiliop56 steveiliop56 merged commit 6112f97 into main Feb 16, 2026
8 checks passed
@Rycochet Rycochet deleted the feat/env-auto-gen branch April 1, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants