Ensure all fibre.Contexts have a unique socket id
This commit is contained in:
parent
bba72ee161
commit
efeb186200
4 changed files with 16 additions and 2 deletions
|
@ -19,6 +19,7 @@ import (
|
||||||
|
|
||||||
"github.com/abcum/fibre"
|
"github.com/abcum/fibre"
|
||||||
"github.com/abcum/surreal/cnf"
|
"github.com/abcum/surreal/cnf"
|
||||||
|
"github.com/abcum/surreal/util/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupDB(workers ...int) {
|
func setupDB(workers ...int) {
|
||||||
|
@ -52,6 +53,7 @@ func setupKV() *fibre.Context {
|
||||||
res := &fibre.Response{}
|
res := &fibre.Response{}
|
||||||
|
|
||||||
ctx := fibre.NewContext(req, res, nil)
|
ctx := fibre.NewContext(req, res, nil)
|
||||||
|
ctx.Set("id", uuid.New().String())
|
||||||
ctx.Set("auth", auth)
|
ctx.Set("auth", auth)
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
@ -71,6 +73,7 @@ func setupSC() *fibre.Context {
|
||||||
res := &fibre.Response{}
|
res := &fibre.Response{}
|
||||||
|
|
||||||
ctx := fibre.NewContext(req, res, nil)
|
ctx := fibre.NewContext(req, res, nil)
|
||||||
|
ctx.Set("id", uuid.New().String())
|
||||||
ctx.Set("auth", auth)
|
ctx.Set("auth", auth)
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/abcum/surreal/mem"
|
"github.com/abcum/surreal/mem"
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
|
"github.com/abcum/surreal/util/uuid"
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
@ -105,10 +106,14 @@ func signinInternal(c *fibre.Context, vars map[string]interface{}) (str string,
|
||||||
c.Fibre(),
|
c.Fibre(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure we copy the session od.
|
// Ensure we copy the session id.
|
||||||
|
|
||||||
t.Set(varKeyUniq, c.Get(varKeyUniq))
|
t.Set(varKeyUniq, c.Get(varKeyUniq))
|
||||||
|
|
||||||
|
// Create a new socket request id.
|
||||||
|
|
||||||
|
t.Set(varKeySock, uuid.New().String())
|
||||||
|
|
||||||
// Give full permissions to scope.
|
// Give full permissions to scope.
|
||||||
|
|
||||||
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB})
|
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB})
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/abcum/surreal/mem"
|
"github.com/abcum/surreal/mem"
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
|
"github.com/abcum/surreal/util/uuid"
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -104,10 +105,14 @@ func signupInternal(c *fibre.Context, vars map[string]interface{}) (str string,
|
||||||
c.Fibre(),
|
c.Fibre(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure we copy the session od.
|
// Ensure we copy the session id.
|
||||||
|
|
||||||
t.Set(varKeyUniq, c.Get(varKeyUniq))
|
t.Set(varKeyUniq, c.Get(varKeyUniq))
|
||||||
|
|
||||||
|
// Create a new socket request id.
|
||||||
|
|
||||||
|
t.Set(varKeySock, uuid.New().String())
|
||||||
|
|
||||||
// Give full permissions to scope.
|
// Give full permissions to scope.
|
||||||
|
|
||||||
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB})
|
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB})
|
||||||
|
|
|
@ -22,6 +22,7 @@ const (
|
||||||
varKeyUs = "US"
|
varKeyUs = "US"
|
||||||
varKeyTb = "TB"
|
varKeyTb = "TB"
|
||||||
varKeyId = "ID"
|
varKeyId = "ID"
|
||||||
|
varKeySock = "id"
|
||||||
varKeyAuth = "auth"
|
varKeyAuth = "auth"
|
||||||
varKeyUser = "user"
|
varKeyUser = "user"
|
||||||
varKeyPass = "pass"
|
varKeyPass = "pass"
|
||||||
|
|
Loading…
Reference in a new issue