@@ -17,11 +17,11 @@ limitations under the License.
1717package keystone
1818
1919import (
20- "log"
2120 "github.com/gophercloud/gophercloud"
21+ "log"
2222
23- "k8s.io/apiserver/pkg/authorization/authorizer"
2423 "encoding/json"
24+ "k8s.io/apiserver/pkg/authorization/authorizer"
2525)
2626
2727type KeystoneAuthorizer struct {
@@ -96,7 +96,7 @@ func nonResourceMatches(p Policy, a authorizer.Attributes) bool {
9696func match (match Match , attributes authorizer.Attributes ) bool {
9797 user := attributes .GetUser ()
9898 if match .Type == "group" {
99- for _ , group := range user .GetGroups () {
99+ for _ , group := range user .GetGroups () {
100100 if match .Value == "*" || group == match .Value {
101101 return true
102102 }
@@ -143,7 +143,7 @@ func match(match Match, attributes authorizer.Attributes) bool {
143143 return false
144144}
145145
146- func (KeystoneAuthorizer * KeystoneAuthorizer ) Authorize (a authorizer.Attributes ) (authorized bool , reason string , err error ) {
146+ func (KeystoneAuthorizer * KeystoneAuthorizer ) Authorize (a authorizer.Attributes ) (authorized authorizer. Decision , reason string , err error ) {
147147 log .Printf ("Authorizing user : %#v\n " , a .GetUser ())
148148 for _ , p := range KeystoneAuthorizer .pl {
149149 if p .NonResourceSpec != nil && p .ResourceSpec != nil {
@@ -152,13 +152,13 @@ func (KeystoneAuthorizer *KeystoneAuthorizer) Authorize(a authorizer.Attributes)
152152 }
153153 if p .ResourceSpec != nil {
154154 if resourceMatches (* p , a ) {
155- return true , "" , nil
155+ return authorizer . DecisionAllow , "" , nil
156156 }
157157 } else if p .NonResourceSpec != nil {
158158 if nonResourceMatches (* p , a ) {
159- return true , "" , nil
159+ return authorizer . DecisionAllow , "" , nil
160160 }
161161 }
162162 }
163- return false , "No policy matched." , nil
163+ return authorizer . DecisionDeny , "No policy matched." , nil
164164}
0 commit comments