-
-
Notifications
You must be signed in to change notification settings - Fork 233
refactor: rework user context handling throughout tinyauth #829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 19 commits
eec75a6
c7efb71
b426a15
97d58b3
9a21904
2f24f82
b4eb709
a3ec072
62ffd2f
df56708
004df2f
c932817
26daef7
ff3c25c
8f337aa
3b5da06
4d3860f
e13598b
eab9f71
36d4e3e
f3965a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,17 @@ import ( | |
| "fmt" | ||
| "slices" | ||
|
|
||
| "github.com/tinyauthapp/tinyauth/internal/config" | ||
| "github.com/tinyauthapp/tinyauth/internal/controller" | ||
| "github.com/tinyauthapp/tinyauth/internal/middleware" | ||
| "github.com/tinyauthapp/tinyauth/internal/model" | ||
|
|
||
| "github.com/gin-gonic/gin" | ||
| ) | ||
|
|
||
| var DEV_MODES = []string{"main", "test", "development"} | ||
|
|
||
| func (app *BootstrapApp) setupRouter() (*gin.Engine, error) { | ||
| if !slices.Contains(DEV_MODES, config.Version) { | ||
| if !slices.Contains(DEV_MODES, model.Version) { | ||
| gin.SetMode(gin.ReleaseMode) | ||
| } | ||
|
|
||
|
|
@@ -30,7 +30,8 @@ func (app *BootstrapApp) setupRouter() (*gin.Engine, error) { | |
| } | ||
|
|
||
| contextMiddleware := middleware.NewContextMiddleware(middleware.ContextMiddlewareConfig{ | ||
| CookieDomain: app.context.cookieDomain, | ||
| CookieDomain: app.context.cookieDomain, | ||
| SessionCookieName: app.context.sessionCookieName, | ||
| }, app.services.authService, app.services.oauthBrokerService) | ||
|
|
||
| err := contextMiddleware.Init() | ||
|
|
@@ -98,7 +99,8 @@ func (app *BootstrapApp) setupRouter() (*gin.Engine, error) { | |
| proxyController.SetupRoutes() | ||
|
|
||
| userController := controller.NewUserController(controller.UserControllerConfig{ | ||
| CookieDomain: app.context.cookieDomain, | ||
| CookieDomain: app.context.cookieDomain, | ||
| SessionCookieName: app.context.sessionCookieName, | ||
| }, apiRouter, app.services.authService) | ||
|
Comment on lines
101
to
104
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The context snippet from if err != nil {
c.Redirect(http.StatusFound, controller.config.SessionCookieName)
return
}
It should redirect to a real path (e.g., - c.Redirect(http.StatusFound, controller.config.SessionCookieName)
+ c.Redirect(http.StatusFound, "/")🤖 Prompt for AI Agents |
||
|
|
||
| userController.SetupRoutes() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't trace raw local user records.
app.context.localUserscontains credential material, so this dump will leak password hashes and TOTP secrets into logs. Please log counts or usernames only here.Suggested change
tlog.App.Trace().Interface("config", app.config).Msg("Config dump") - tlog.App.Trace().Interface("users", app.context.localUsers).Msg("Users dump") + tlog.App.Trace().Int("userCount", len(app.context.localUsers)).Msg("Loaded local users") tlog.App.Trace().Interface("oauthProviders", app.context.oauthProviders).Msg("OAuth providers dump")📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dump is on purpose to help debug Tinyauth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveiliop56, understood — if it's an intentional debug aid, that's your call. Just worth keeping in mind thatTRACE-level logging is sometimes accidentally enabled in production environments (e.g. via a misconfigured env var), which would expose password hashes and TOTP secrets in log output. If you'd like a middle-ground in the future, logging usernames only (no credentials) would still give plenty of debugging signal while reducing that risk. No changes needed from your side!