From 81ca1bd74bfad653315cfd30aebff2c6c43a7bbf Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Wed, 24 Dec 2025 19:19:44 +0100 Subject: Implements cookie authentication enhancements Improves cookie authentication by adding error handling for expired and bad format cookies. Enhances user session management through robust checks and logging, ensuring a secure and reliable authentication process. Updates the README to reflect changes in the authentication mechanism. --- kauth/config.go | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 kauth/config.go (limited to 'kauth/config.go') diff --git a/kauth/config.go b/kauth/config.go deleted file mode 100644 index 777a22d..0000000 --- a/kauth/config.go +++ /dev/null @@ -1,34 +0,0 @@ -package kauth - -import ( - "encoding/hex" - "errors" - "os" - - "github.com/martinlehoux/kagamigo/kcore" - "golang.org/x/exp/slog" -) - -var ( - ErrCookieBadLength = errors.New("cookie secret must be 32 bytes") -) - -type AuthConfig struct { - Domain string - CookieSecret []byte -} - -func LoadCookieSecret(cookieSecretString string) []byte { - cookiesSecret, err := hex.DecodeString(cookieSecretString) - if err != nil { - err = kcore.Wrap(err, "error decoding cookie secret") - slog.Error(err.Error()) - os.Exit(1) - } - if len(cookiesSecret) != 32 { - slog.Error(ErrCookieBadLength.Error()) - os.Exit(1) - } - slog.Info("cookie secret loaded") - return cookiesSecret -} -- cgit v1.3