From e94c48b5767d2837d49fe06744636f8075854922 Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 2 Jul 2023 23:20:52 +0800 Subject: [PATCH] fix: session name generator --- go.mod | 3 +-- go.sum | 2 -- server/server.go | 4 ++-- test/store/workspace_setting_test.go | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index a523c59..1f1c090 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/boojack/shortify go 1.19 -require github.com/google/uuid v1.3.0 // indirect +require github.com/google/uuid v1.3.0 require ( github.com/golang-jwt/jwt v3.2.2+incompatible // indirect @@ -23,7 +23,6 @@ require ( ) require ( - github.com/gorilla/securecookie v1.1.1 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index cd5c3fb..89c08f4 100644 --- a/go.sum +++ b/go.sum @@ -165,8 +165,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= -github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= diff --git a/server/server.go b/server/server.go index 408165f..a34bc77 100644 --- a/server/server.go +++ b/server/server.go @@ -8,8 +8,8 @@ import ( apiv1 "github.com/boojack/shortify/api/v1" "github.com/boojack/shortify/server/profile" "github.com/boojack/shortify/store" + "github.com/google/uuid" - "github.com/gorilla/securecookie" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" ) @@ -98,7 +98,7 @@ func (s *Server) getSystemSecretSessionName(ctx context.Context) (string, error) return "", err } if secretSessionNameValue == nil || secretSessionNameValue.Value == "" { - tempSecret := securecookie.GenerateRandomKey(16) + tempSecret := uuid.New().String() secretSessionNameValue, err = s.Store.UpsertWorkspaceSetting(ctx, &store.WorkspaceSetting{ Key: store.WorkspaceSecretSessionName, Value: string(tempSecret), diff --git a/test/store/workspace_setting_test.go b/test/store/workspace_setting_test.go index 37458ac..0a24818 100644 --- a/test/store/workspace_setting_test.go +++ b/test/store/workspace_setting_test.go @@ -5,14 +5,14 @@ import ( "testing" "github.com/boojack/shortify/store" - "github.com/gorilla/securecookie" + "github.com/google/uuid" "github.com/stretchr/testify/require" ) func TestWorkspaceSettingStore(t *testing.T) { ctx := context.Background() ts := NewTestingStore(ctx, t) - tempSecret := securecookie.GenerateRandomKey(16) + tempSecret := uuid.New().String() workspaceSetting, err := ts.UpsertWorkspaceSetting(ctx, &store.WorkspaceSetting{ Key: store.WorkspaceSecretSessionName, Value: string(tempSecret),