From 535bea1b6b6ca9a476685716f77ce12e0e8e616b Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Wed, 25 May 2016 17:22:33 +0800 Subject: [PATCH] fix #268 --- service/token/authutils.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/service/token/authutils.go b/service/token/authutils.go index 3ea15c294..4c30648c4 100644 --- a/service/token/authutils.go +++ b/service/token/authutils.go @@ -46,10 +46,24 @@ func GetResourceActions(scopes []string) []*token.ResourceActions { continue } items := strings.Split(s, ":") + length := len(items) + + typee := items[0] + + name := "" + if length > 1 { + name = items[1] + } + + actions := []string{} + if length > 2 { + actions = strings.Split(items[2], ",") + } + res = append(res, &token.ResourceActions{ - Type: items[0], - Name: items[1], - Actions: strings.Split(items[2], ","), + Type: typee, + Name: name, + Actions: actions, }) } return res