Ensure all fibre.Contexts have a unique socket id

This commit is contained in:
Tobie Morgan Hitchcock 2019-01-14 16:03:26 +00:00
parent bba72ee161
commit efeb186200
4 changed files with 16 additions and 2 deletions

View file

@ -19,6 +19,7 @@ import (
"github.com/abcum/fibre"
"github.com/abcum/surreal/cnf"
"github.com/abcum/surreal/util/uuid"
)
func setupDB(workers ...int) {
@ -52,6 +53,7 @@ func setupKV() *fibre.Context {
res := &fibre.Response{}
ctx := fibre.NewContext(req, res, nil)
ctx.Set("id", uuid.New().String())
ctx.Set("auth", auth)
return ctx
@ -71,6 +73,7 @@ func setupSC() *fibre.Context {
res := &fibre.Response{}
ctx := fibre.NewContext(req, res, nil)
ctx.Set("id", uuid.New().String())
ctx.Set("auth", auth)
return ctx

View file

@ -24,6 +24,7 @@ import (
"github.com/abcum/surreal/mem"
"github.com/abcum/surreal/sql"
"github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/uuid"
"github.com/dgrijalva/jwt-go"
"golang.org/x/crypto/bcrypt"
)
@ -105,10 +106,14 @@ func signinInternal(c *fibre.Context, vars map[string]interface{}) (str string,
c.Fibre(),
)
// Ensure we copy the session od.
// Ensure we copy the session id.
t.Set(varKeyUniq, c.Get(varKeyUniq))
// Create a new socket request id.
t.Set(varKeySock, uuid.New().String())
// Give full permissions to scope.
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB})

View file

@ -24,6 +24,7 @@ import (
"github.com/abcum/surreal/mem"
"github.com/abcum/surreal/sql"
"github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/uuid"
"github.com/dgrijalva/jwt-go"
)
@ -104,10 +105,14 @@ func signupInternal(c *fibre.Context, vars map[string]interface{}) (str string,
c.Fibre(),
)
// Ensure we copy the session od.
// Ensure we copy the session id.
t.Set(varKeyUniq, c.Get(varKeyUniq))
// Create a new socket request id.
t.Set(varKeySock, uuid.New().String())
// Give full permissions to scope.
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB})

View file

@ -22,6 +22,7 @@ const (
varKeyUs = "US"
varKeyTb = "TB"
varKeyId = "ID"
varKeySock = "id"
varKeyAuth = "auth"
varKeyUser = "user"
varKeyPass = "pass"