Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit c0b0873

Browse files
committed
update dependencies and run make fmt
1 parent 5b8c213 commit c0b0873

7 files changed

Lines changed: 31 additions & 26 deletions

File tree

cmd/k8s-keystone-auth/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"log"
2020
"net/http"
2121

22-
"github.com/dims/k8s-keystone-auth/pkg/authenticator/token/keystone"
23-
"github.com/dims/k8s-keystone-auth/pkg/identity/webhook"
22+
"git.openstack.org/openstack/openstack-cloud-controller-manager/pkg/authenticator/token/keystone"
23+
"git.openstack.org/openstack/openstack-cloud-controller-manager/pkg/identity/webhook"
2424
"k8s.io/apiserver/pkg/authentication/authenticator"
2525
"k8s.io/apiserver/pkg/authorization/authorizer"
2626
)

glide.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import:
2727
- openstack/networking/v2/extensions/security/rules
2828
- openstack/networking/v2/networks
2929
- openstack/networking/v2/ports
30+
- openstack/utils
3031
- pagination
3132
- package: github.com/kubernetes-incubator/external-storage
3233
repo: https://github.com/dims/external-storage
@@ -57,6 +58,9 @@ import:
5758
- package: k8s.io/apiserver
5859
version: kubernetes-1.9.2
5960
subpackages:
61+
- pkg/authentication/authenticator
62+
- pkg/authentication/user
63+
- pkg/authorization/authorizer
6064
- pkg/server/healthz
6165
- pkg/util/flag
6266
- pkg/util/logs

pkg/authenticator/token/keystone/authorizer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ limitations under the License.
1717
package keystone
1818

1919
import (
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

2727
type KeystoneAuthorizer struct {
@@ -96,7 +96,7 @@ func nonResourceMatches(p Policy, a authorizer.Attributes) bool {
9696
func 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
}

pkg/authenticator/token/keystone/keystone.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package keystone
1818

1919
import (
2020
"crypto/tls"
21-
"errors"
2221
"encoding/json"
22+
"errors"
2323
"fmt"
24-
"net/http"
2524
"log"
25+
"net/http"
2626
//"strings"
2727

2828
"github.com/golang/glog"
@@ -127,5 +127,5 @@ func NewKeystoneAuthorizer(authURL string, caFile string, policyFile string) (*K
127127
log.Fatalf(">>> Error %#v", err)
128128
}
129129

130-
return &KeystoneAuthorizer{authURL: authURL, client: client, pl:policyList}, nil
131-
}
130+
return &KeystoneAuthorizer{authURL: authURL, client: client, pl: policyList}, nil
131+
}

pkg/authenticator/token/keystone/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ limitations under the License.
1717
package keystone
1818

1919
import (
20-
"os"
2120
"bufio"
2221
"encoding/json"
22+
"os"
2323
)
2424

2525
type Policy struct {

pkg/identity/webhook/handlers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"net/http"
2121

2222
"k8s.io/apiserver/pkg/authentication/authenticator"
23-
"k8s.io/apiserver/pkg/authorization/authorizer"
2423
"k8s.io/apiserver/pkg/authentication/user"
24+
"k8s.io/apiserver/pkg/authorization/authorizer"
2525
"log"
2626
)
2727

@@ -126,28 +126,28 @@ func (h *WebhookHandler) authorizeToken(w http.ResponseWriter, r *http.Request,
126126

127127
spec := data["spec"].(map[string]interface{})
128128

129-
username := spec["user"]
129+
username := spec["user"]
130130
usr := &user.DefaultInfo{
131-
Name: username.(string),
131+
Name: username.(string),
132132
}
133133
attrs := authorizer.AttributesRecord{
134134
User: usr,
135135
}
136136

137137
groups := spec["group"].([]interface{})
138138
for _, v := range groups {
139-
usr.Groups = append(usr.Groups, v.(string))
139+
usr.Groups = append(usr.Groups, v.(string))
140140
}
141141
if extras, ok := spec["extra"].(map[string]interface{}); ok {
142142
usr.Extra = make(map[string][]string, len(extras))
143143
for key, value := range extras {
144-
for _,v := range value.([]interface{}) {
145-
if data, ok := usr.Extra[key] ; ok {
146-
usr.Extra[key] = append(data, v.(string))
147-
} else {
148-
usr.Extra[key] = []string{v.(string)}
149-
}
144+
for _, v := range value.([]interface{}) {
145+
if data, ok := usr.Extra[key]; ok {
146+
usr.Extra[key] = append(data, v.(string))
147+
} else {
148+
usr.Extra[key] = []string{v.(string)}
150149
}
150+
}
151151
}
152152
}
153153

0 commit comments

Comments
 (0)