feat: auto generate example env file#647
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughCentralizes runtime defaults into a new config factory, replaces concrete Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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: Addgenerateto.PHONY.Without a
.PHONYdeclaration, if a file or directory namedgenerateexists in the repo root,make generatewill silently no-op. Same applies to other non-file targets likedevanddev-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 toconst.These values are not set via
-ldflags, never reassigned, and serve only as immutable template values for generating runtime cookie names. Usingconstprevents 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.
There was a problem hiding this comment.
🤖 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_keyand./tinyauth_oidc_key.pub) differ from the project's recommended defaults. Based on learnings, the OIDC service should usedata/oidc-private.keyanddata/oidc-public.keyas 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.
There was a problem hiding this comment.
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.
Summary by CodeRabbit