fix: session name generator

This commit is contained in:
Steven 2023-07-02 23:20:52 +08:00
parent ff8b92aa66
commit e94c48b576
4 changed files with 5 additions and 8 deletions

3
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

View File

@ -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),

View File

@ -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),