From 5bfe938fcf6737664eec23ca8073907f869f021a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 21 Nov 2016 18:58:07 +0000 Subject: [PATCH] Enable authentication tokens on SCOPES --- sql/token.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sql/token.go b/sql/token.go index 8020aa8c..59161ad3 100644 --- a/sql/token.go +++ b/sql/token.go @@ -22,7 +22,7 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er return nil, err } - if stmt.Kind, _, err = p.shouldBe(NAMESPACE, DATABASE); err != nil { + if stmt.Kind, _, err = p.shouldBe(NAMESPACE, DATABASE, SCOPE); err != nil { return nil, err } @@ -38,6 +38,12 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er } } + if p.is(stmt.Kind, SCOPE) { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { + return nil, err + } + } + if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { return nil, err } @@ -54,7 +60,7 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er return nil, err } - if stmt.Kind, _, err = p.shouldBe(NAMESPACE, DATABASE); err != nil { + if stmt.Kind, _, err = p.shouldBe(NAMESPACE, DATABASE, SCOPE); err != nil { return nil, err } @@ -70,6 +76,12 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er } } + if p.is(stmt.Kind, SCOPE) { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { + return nil, err + } + } + if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { return nil, err }