From d5b9567663b6f94191853bcbed70dff97ed8ffdb Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 7 Jul 2018 23:35:29 +0200 Subject: [PATCH] fix middleware + add example for manifest scope --- manifest.json | 6 +++--- middleware/1-auth/main.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index af492f4..16a033a 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "POST": { "info": "creates a new tiny url", - "scope": [[]], + "scope": [["admin"]], "in": { "URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" }, "target": { "info": "url to shorten", "type": "varchar(5,300)" } @@ -20,7 +20,7 @@ "PUT": { "info": "overrides an existing tiny url", - "scope": [[]], + "scope": [["admin"]], "in": { "URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" }, "target": { "info": "url to shorten", "type": "varchar(5,300)" } @@ -30,7 +30,7 @@ "DELETE": { "info": "removes an existing tiny url", - "scope": [[]], + "scope": [["admin"]], "in": { "URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" } }, diff --git a/middleware/1-auth/main.go b/middleware/1-auth/main.go index a177db9..6bfcc9d 100644 --- a/middleware/1-auth/main.go +++ b/middleware/1-auth/main.go @@ -6,6 +6,6 @@ import ( ) // Authentication middleware -func Inspect(req http.Request, scope middleware.Scope){ - scope = append(scope, "user"); +func Inspect(req http.Request, scope *middleware.Scope) { + *scope = append(*scope, "admin") }