Skip to content

Commit

Permalink
Merge pull request #3875 from aledbf/fix-auth-secret
Browse files Browse the repository at this point in the history
Allow the use of a secret located in a different namespace
  • Loading branch information
k8s-ci-robot authored Mar 11, 2019
2 parents 8e7480e + d403b3e commit 8690958
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/ingress/annotations/auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/pkg/errors"
api "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/client-go/tools/cache"

"k8s.io/ingress-nginx/internal/file"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
Expand Down Expand Up @@ -108,7 +109,18 @@ func (a auth) Parse(ing *extensions.Ingress) (interface{}, error) {
}
}

name := fmt.Sprintf("%v/%v", ing.Namespace, s)
sns, sname, err := cache.SplitMetaNamespaceKey(s)
if err != nil {
return nil, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "error reading secret name from annotation"),
}
}

if sns == "" {
sns = ing.Namespace
}

name := fmt.Sprintf("%v/%v", sns, sname)
secret, err := a.r.GetSecret(name)
if err != nil {
return nil, ing_errors.LocationDenied{
Expand Down

0 comments on commit 8690958

Please sign in to comment.