diff --git a/internal/handler.go b/internal/handler.go index d2b311d..0fe9cdd 100644 --- a/internal/handler.go +++ b/internal/handler.go @@ -160,7 +160,7 @@ func (oauth *OauthRulerMiddleware) callbackHandler(w http.ResponseWriter, r *htt } // Save token to a cookie for simplicity http.SetCookie(w, &http.Cookie{ - Name: "goma.JWT", + Name: "goma.oauth", Value: jwtToken, Path: oauth.CookiePath, }) diff --git a/internal/middleware/oauth-middleware.go b/internal/middleware/oauth-middleware.go index e3c6e5e..1697ae1 100644 --- a/internal/middleware/oauth-middleware.go +++ b/internal/middleware/oauth-middleware.go @@ -20,17 +20,15 @@ package middleware import ( "fmt" "github.com/golang-jwt/jwt" - "github.com/jkaninda/goma-gateway/pkg/logger" "net/http" "time" ) func (oauth Oauth) AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - logger.Info("%s: %s Oauth", getRealIP(r), r.URL.Path) oauthConf := oauth2Config(oauth) // Check if the user is authenticated - token, err := r.Cookie("goma.JWT") + token, err := r.Cookie("goma.oauth") if err != nil { // If no token, redirect to OAuth provider url := oauthConf.AuthCodeURL(oauth.State)