diff --git a/db/db.go b/db/db.go index 1ca06068..352cf554 100644 --- a/db/db.go +++ b/db/db.go @@ -203,13 +203,6 @@ func Process(fib *fibre.Context, ast *sql.Query, vars map[string]interface{}) (o ctx = context.WithValue(ctx, ctxKeyId, id) - // Assign any global connection variables - // to the context so that we can retrieve - // the variables from within any queries. - - keep := fib.Get(varKeyKeep) - ctx = context.WithValue(ctx, ctxKeyKeep, keep) - // Assign the authentication data to the // context so that we can log the auth kind // and the auth variable data to the request. diff --git a/db/executor.go b/db/executor.go index f6f58881..392a950c 100644 --- a/db/executor.go +++ b/db/executor.go @@ -117,7 +117,6 @@ func (e *executor) execute(ctx context.Context, ast *sql.Query) { "id": ctx.Value(ctxKeyId), "kind": ctx.Value(ctxKeyKind), "vars": ctx.Value(ctxKeyVars), - "keep": ctx.Value(ctxKeyKeep), }) if stm, ok := stm.(sql.AuthableStatement); ok { diff --git a/db/socket.go b/db/socket.go index 18f6320e..0feea446 100644 --- a/db/socket.go +++ b/db/socket.go @@ -61,9 +61,6 @@ func (s *socket) ctx(ns, db string) (ctx context.Context) { ctx = context.WithValue(ctx, ctxKeyNs, ns) ctx = context.WithValue(ctx, ctxKeyDb, db) - keep := s.fibre.Get(ctxKeyKeep) - ctx = context.WithValue(ctx, ctxKeyKeep, keep) - auth := s.fibre.Get(ctxKeyAuth).(*cnf.Auth) ctx = context.WithValue(ctx, ctxKeyAuth, auth.Data) ctx = context.WithValue(ctx, ctxKeyKind, auth.Kind) diff --git a/db/vars.go b/db/vars.go index a9b90283..bc3c77be 100644 --- a/db/vars.go +++ b/db/vars.go @@ -49,7 +49,6 @@ const ( ctxKeyVars = "vars" ctxKeySubs = "subs" ctxKeySpec = "spec" - ctxKeyKeep = "keep" ctxKeyAuth = "auth" ctxKeyKind = "kind" ctxKeyScope = "scope" @@ -62,7 +61,6 @@ const ( varKeyIp = "ip" varKeyEnv = "ENV" varKeyAuth = "auth" - varKeyKeep = "keep" varKeyThis = "this" varKeyScope = "scope" varKeyValue = "value" @@ -108,5 +106,5 @@ var ( // paramSearchKeys specifies the order in which context // variables should be checked for any specified value. - paramSearchKeys = []string{ctxKeySpec, ctxKeySubs, ctxKeyVars, ctxKeyKeep} + paramSearchKeys = []string{ctxKeySpec, ctxKeySubs, ctxKeyVars} ) diff --git a/web/auth.go b/web/auth.go index d686718e..b2d03ac5 100644 --- a/web/auth.go +++ b/web/auth.go @@ -31,30 +31,12 @@ import ( "github.com/abcum/surreal/sql" "github.com/dgrijalva/jwt-go" "github.com/gorilla/websocket" - - "github.com/abcum/surreal/util/data" ) var ignore = func() error { return nil } -const ( - varKeyIp = "ip" - varKeyNs = "NS" - varKeyDb = "DB" - varKeySc = "SC" - varKeyTk = "TK" - varKeyUs = "US" - varKeyTb = "TB" - varKeyId = "ID" - varKeyAuth = "auth" - varKeyKeep = "keep" - varKeyUser = "user" - varKeyPass = "pass" - varKeyOrigin = "origin" -) - func cidr(ip net.IP, networks []*net.IPNet) bool { for _, network := range networks { if network.Contains(ip) { @@ -68,13 +50,6 @@ func auth() fibre.MiddlewareFunc { return func(h fibre.HandlerFunc) fibre.HandlerFunc { return func(c *fibre.Context) (err error) { - // Initialise any session level variables - // which will be valid across all requests - // which are made over this connection. - - vars := new(data.Doc) - c.Set(varKeyKeep, vars) - // Initialise the connection authentication // information which will store whether the // connection has authenticated or not. diff --git a/web/rpc.go b/web/rpc.go index 8a08e760..a58e52a5 100644 --- a/web/rpc.go +++ b/web/rpc.go @@ -19,8 +19,6 @@ import ( "github.com/abcum/surreal/cnf" "github.com/abcum/surreal/db" "github.com/abcum/surreal/sql" - "github.com/abcum/surreal/util/data" - "github.com/abcum/surreal/util/rand" ) type rpc struct{} @@ -29,8 +27,6 @@ type rpc struct{} // Methods for authentication // -------------------------------------------------- -func (r *rpc) Uniq(c *fibre.Context) (interface{}, error) { - return rand.String(64), nil func (r *rpc) Ping(c *fibre.Context) (interface{}, error) { return "OK", nil } @@ -75,10 +71,6 @@ func (r *rpc) Live(c *fibre.Context, class string) (interface{}, error) { // Methods for static queries // -------------------------------------------------- -func (r *rpc) Let(c *fibre.Context, key string, val interface{}) (interface{}, error) { - return c.Get("keep").(*data.Doc).Set(val, key) -} - func (r *rpc) Query(c *fibre.Context, sql string, vars map[string]interface{}) (interface{}, error) { return db.Execute(c, sql, vars) } diff --git a/web/vars.go b/web/vars.go new file mode 100644 index 00000000..767f8153 --- /dev/null +++ b/web/vars.go @@ -0,0 +1,28 @@ +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package web + +const ( + varKeyNs = "NS" + varKeyDb = "DB" + varKeySc = "SC" + varKeyTk = "TK" + varKeyUs = "US" + varKeyTb = "TB" + varKeyId = "ID" + varKeyAuth = "auth" + varKeyUser = "user" + varKeyPass = "pass" +)