From caf5bb2ee84079365996a622ab8fc5ed510ef9a7 Mon Sep 17 00:00:00 2001 From: T Date: Sat, 5 Jul 2025 09:41:47 -0600 Subject: Add Auth.Clear() method and enhance middlewares to clear invalid cookies - Add Auth.Clear() method that creates expired cookies (MaxAge: -1) to log out users - Enhance Clear() to remove existing Set-Cookie headers to comply with RFC 6265 - Update Required() and Optional() middlewares to automatically clear invalid cookies - Add comprehensive tests for all new functionality - Update documentation with Auth.Clear() usage examples --- README.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index d5d7882..da36cad 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,9 @@ http.Handle("GET /protected", auth.Required(protectedHandler)) user := UserData{ID: 123, Name: "John"} auth.Set(w, user) +// Clear authentication cookie (logout) +auth.Clear(w) + // Get authenticated data user, ok := auth.Get(r.Context()) ``` -- cgit v1.2.3