From 47284a79c2ff99813058f401259b86bbbcabdbae Mon Sep 17 00:00:00 2001 From: mountain Date: Thu, 31 Aug 2023 20:44:21 +0900 Subject: [PATCH] =?UTF-8?q?session=20provider=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=B5=9C=EC=8B=A0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/maingate.go | 16 +++++----------- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/core/maingate.go b/core/maingate.go index fda15d8..ab416f9 100644 --- a/core/maingate.go +++ b/core/maingate.go @@ -147,6 +147,10 @@ func New(ctx context.Context) (*Maingate, error) { admins.parse() } + if len(config.SessionStorage) == 0 { + return nil, errors.New("maingate_session_storage is missing") + } + if config.SessionTTL == 0 { config.SessionTTL = 3600 } @@ -331,17 +335,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) { return makeErrorWithStack(err) } - if len(mg.SessionStorage) > 0 { - if strings.HasPrefix(mg.SessionStorage, "mongodb") { - mg.sessionProvider, err = session.NewProviderWithMongo(context, mg.SessionStorage, "maingate", time.Duration(mg.SessionTTL*int64(time.Second))) - } else if strings.HasPrefix(mg.SessionStorage, "redis") { - mg.sessionProvider, err = session.NewProviderWithRedis(context, mg.SessionStorage, time.Duration(mg.SessionTTL*int64(time.Second))) - } else { - err = fmt.Errorf("sessio storage is not valid :%s", mg.SessionStorage) - } - } else { - mg.sessionProvider, err = session.NewProviderWithMongo(context, mg.Mongo, "maingate", time.Duration(mg.SessionTTL*int64(time.Second))) - } + mg.sessionProvider, err = session.NewProvider(context, mg.SessionStorage, time.Duration(mg.SessionTTL*int64(time.Second))) if err != nil { return makeErrorWithStack(err) diff --git a/go.mod b/go.mod index 2c78c65..cba7487 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang-jwt/jwt v3.2.2+incompatible go.mongodb.org/mongo-driver v1.11.7 google.golang.org/api v0.128.0 - repositories.action2quare.com/ayo/gocommon v0.0.0-20230831053308-cde46e6a5fdb + repositories.action2quare.com/ayo/gocommon v0.0.0-20230831113900-57b518562eac ) require ( diff --git a/go.sum b/go.sum index 25893b0..d4adc51 100644 --- a/go.sum +++ b/go.sum @@ -341,3 +341,5 @@ repositories.action2quare.com/ayo/gocommon v0.0.0-20230830073522-021f18315726 h1 repositories.action2quare.com/ayo/gocommon v0.0.0-20230830073522-021f18315726/go.mod h1:PdpZ16O1czKKxCxn+0AFNaEX/0kssYwC3G8jR0V7ybw= repositories.action2quare.com/ayo/gocommon v0.0.0-20230831053308-cde46e6a5fdb h1:F7BxLeUeJoBnE+5VCMuKimceSYmhdH2dQSzmyBzc4+M= repositories.action2quare.com/ayo/gocommon v0.0.0-20230831053308-cde46e6a5fdb/go.mod h1:PdpZ16O1czKKxCxn+0AFNaEX/0kssYwC3G8jR0V7ybw= +repositories.action2quare.com/ayo/gocommon v0.0.0-20230831113900-57b518562eac h1:LFWGF8pTmYujUil9RNyRcZP+lY+w54na0NfSDLGiz6U= +repositories.action2quare.com/ayo/gocommon v0.0.0-20230831113900-57b518562eac/go.mod h1:PdpZ16O1czKKxCxn+0AFNaEX/0kssYwC3G8jR0V7ybw=