Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cc357f3
feat: add new logger
steveiliop56 May 7, 2026
592c221
refactor: use one struct for context handling and cancellation
steveiliop56 May 7, 2026
112a30f
refactor: rework logging and config in controllers
steveiliop56 May 8, 2026
55b53c7
refactor: rework logging and config in middlewares
steveiliop56 May 8, 2026
e214d6d
refactor: rework logging and cancellation in services
steveiliop56 May 8, 2026
0958c3b
refactor: rework cli logging
steveiliop56 May 8, 2026
b73a9db
fix: improve logging in routines
steveiliop56 May 8, 2026
71ddfbb
feat: use sync groups for better cancellation
steveiliop56 May 8, 2026
8c8d56f
refactor: simplify middleware, controller and service init
steveiliop56 May 9, 2026
9fccb63
tests: fix controller tests
steveiliop56 May 9, 2026
c7e9fad
tests: use require instead of assert where previous step is required
steveiliop56 May 9, 2026
a76141a
tests: fix middleware tests
steveiliop56 May 9, 2026
74aca0f
tests: fix service tests
steveiliop56 May 9, 2026
886f9a8
tests: fix context tests
steveiliop56 May 9, 2026
02b48aa
fix: fix typos
steveiliop56 May 9, 2026
4e760e8
feat: add option to enable or disable concurrent listeners
steveiliop56 May 9, 2026
3d9c81d
fix: assign public key correctly in oidc server
steveiliop56 May 9, 2026
548d97f
tests: fix don't try to test logger with char size
steveiliop56 May 9, 2026
d500907
fix: coderabbit comments
steveiliop56 May 9, 2026
e739aa8
tests: use filepath join instead of path join
steveiliop56 May 9, 2026
11b6155
fix: ensure unix socket shutdown doesn't run twice
steveiliop56 May 10, 2026
d387847
chore: remove temp lint file
steveiliop56 May 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cmd/tinyauth/create_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"

"charm.land/huh/v2"
"github.com/tinyauthapp/tinyauth/internal/utils/tlog"
"github.com/tinyauthapp/paerser/cli"
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
"golang.org/x/crypto/bcrypt"
)

Expand Down Expand Up @@ -40,7 +40,8 @@ func createUserCmd() *cli.Command {
Configuration: tCfg,
Resources: loaders,
Run: func(_ []string) error {
tlog.NewSimpleLogger().Init()
log := logger.NewLogger().WithSimpleConfig()
log.Init()

if tCfg.Interactive {
form := huh.NewForm(
Expand Down Expand Up @@ -73,7 +74,7 @@ func createUserCmd() *cli.Command {
return errors.New("username and password cannot be empty")
}

tlog.App.Info().Str("username", tCfg.Username).Msg("Creating user")
log.App.Info().Str("username", tCfg.Username).Msg("Creating user")

passwd, err := bcrypt.GenerateFromPassword([]byte(tCfg.Password), bcrypt.DefaultCost)
if err != nil {
Expand All @@ -86,7 +87,7 @@ func createUserCmd() *cli.Command {
passwdStr = strings.ReplaceAll(passwdStr, "$", "$$")
}

tlog.App.Info().Str("user", fmt.Sprintf("%s:%s", tCfg.Username, passwdStr)).Msg("User created")
log.App.Info().Str("user", fmt.Sprintf("%s:%s", tCfg.Username, passwdStr)).Msg("User created")

return nil
},
Expand Down
11 changes: 6 additions & 5 deletions cmd/tinyauth/generate_totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/tinyauthapp/tinyauth/internal/utils"
"github.com/tinyauthapp/tinyauth/internal/utils/tlog"
"github.com/tinyauthapp/tinyauth/internal/utils/logger"

"charm.land/huh/v2"
"github.com/mdp/qrterminal/v3"
Expand Down Expand Up @@ -40,7 +40,8 @@ func generateTotpCmd() *cli.Command {
Configuration: tCfg,
Resources: loaders,
Run: func(_ []string) error {
tlog.NewSimpleLogger().Init()
log := logger.NewLogger().WithSimpleConfig()
log.Init()

if tCfg.Interactive {
form := huh.NewForm(
Expand Down Expand Up @@ -88,9 +89,9 @@ func generateTotpCmd() *cli.Command {

secret := key.Secret()

tlog.App.Info().Str("secret", secret).Msg("Generated TOTP secret")
log.App.Info().Str("secret", secret).Msg("Generated TOTP secret")

tlog.App.Info().Msg("Generated QR code")
log.App.Info().Msg("Generated QR code")

config := qrterminal.Config{
Level: qrterminal.L,
Expand All @@ -109,7 +110,7 @@ func generateTotpCmd() *cli.Command {
user.Password = strings.ReplaceAll(user.Password, "$", "$$")
}

tlog.App.Info().Str("user", fmt.Sprintf("%s:%s:%s", user.Username, user.Password, user.TOTPSecret)).Msg("Add the totp secret to your authenticator app then use the verify command to ensure everything is working correctly.")
log.App.Info().Str("user", fmt.Sprintf("%s:%s:%s", user.Username, user.Password, user.TOTPSecret)).Msg("Add the totp secret to your authenticator app then use the verify command to ensure everything is working correctly.")

return nil
},
Expand Down
9 changes: 5 additions & 4 deletions cmd/tinyauth/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os"
"time"

"github.com/tinyauthapp/tinyauth/internal/utils/tlog"
"github.com/tinyauthapp/paerser/cli"
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
)

type healthzResponse struct {
Expand All @@ -26,7 +26,8 @@ func healthcheckCmd() *cli.Command {
Resources: nil,
AllowArg: true,
Run: func(args []string) error {
tlog.NewSimpleLogger().Init()
log := logger.NewLogger().WithSimpleConfig()
log.Init()

srvAddr := os.Getenv("TINYAUTH_SERVER_ADDRESS")
if srvAddr == "" {
Expand All @@ -48,7 +49,7 @@ func healthcheckCmd() *cli.Command {
return errors.New("Could not determine app URL")
}

tlog.App.Info().Str("app_url", appUrl).Msg("Performing health check")
log.App.Info().Str("app_url", appUrl).Msg("Performing health check")

client := http.Client{
Timeout: 30 * time.Second,
Expand Down Expand Up @@ -86,7 +87,7 @@ func healthcheckCmd() *cli.Command {
return fmt.Errorf("failed to decode response: %w", err)
}

tlog.App.Info().Interface("response", healthResp).Msg("Tinyauth is healthy")
log.App.Info().Interface("response", healthResp).Msg("Tinyauth is healthy")

return nil
},
Expand Down
6 changes: 0 additions & 6 deletions cmd/tinyauth/tinyauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/tinyauthapp/tinyauth/internal/bootstrap"
"github.com/tinyauthapp/tinyauth/internal/model"
"github.com/tinyauthapp/tinyauth/internal/utils/loaders"
"github.com/tinyauthapp/tinyauth/internal/utils/tlog"

"github.com/rs/zerolog/log"
"github.com/tinyauthapp/paerser/cli"
Expand Down Expand Up @@ -109,11 +108,6 @@ func main() {
}

func runCmd(cfg model.Config) error {
logger := tlog.NewLogger(cfg.Log)
logger.Init()

tlog.App.Info().Str("version", model.Version).Msg("Starting tinyauth")

app := bootstrap.NewBootstrapApp(cfg)

err := app.Setup()
Expand Down
11 changes: 6 additions & 5 deletions cmd/tinyauth/verify_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/tinyauthapp/tinyauth/internal/utils"
"github.com/tinyauthapp/tinyauth/internal/utils/tlog"
"github.com/tinyauthapp/tinyauth/internal/utils/logger"

"charm.land/huh/v2"
"github.com/pquerna/otp/totp"
Expand Down Expand Up @@ -44,7 +44,8 @@ func verifyUserCmd() *cli.Command {
Configuration: tCfg,
Resources: loaders,
Run: func(_ []string) error {
tlog.NewSimpleLogger().Init()
log := logger.NewLogger().WithSimpleConfig()
log.Init()

if tCfg.Interactive {
form := huh.NewForm(
Expand Down Expand Up @@ -97,9 +98,9 @@ func verifyUserCmd() *cli.Command {

if user.TOTPSecret == "" {
if tCfg.Totp != "" {
tlog.App.Warn().Msg("User does not have TOTP secret")
log.App.Warn().Msg("User does not have TOTP secret")
}
tlog.App.Info().Msg("User verified")
log.App.Info().Msg("User verified")
return nil
}

Expand All @@ -109,7 +110,7 @@ func verifyUserCmd() *cli.Command {
return fmt.Errorf("TOTP code incorrect")
}

tlog.App.Info().Msg("User verified")
log.App.Info().Msg("User verified")

return nil
},
Expand Down
Loading
Loading