This commit is contained in:
Dominik Hahn 2017-11-08 12:03:05 +00:00 committed by GitHub
commit 2c183cbd2c
3 changed files with 8 additions and 3 deletions

View file

@ -10,6 +10,11 @@ Re-type new password:
Adding password for user foo Adding password for user foo
``` ```
To create your file without `htpasswd`
```console
$ printf "foo:$(openssl passwd -crypt <bar>)\n" >> auth
```
```console ```console
$ kubectl create secret generic basic-auth --from-file=auth $ kubectl create secret generic basic-auth --from-file=auth
secret "basic-auth" created secret "basic-auth" created
@ -19,7 +24,7 @@ secret "basic-auth" created
$ kubectl get secret basic-auth -o yaml $ kubectl get secret basic-auth -o yaml
apiVersion: v1 apiVersion: v1
data: data:
auth: Zm9vOiRhcHIxJE9GRzNYeWJwJGNrTDBGSERBa29YWUlsSDkuY3lzVDAK kube-ingress-auth: Zm9vOiRhcHIxJE9GRzNYeWJwJGNrTDBGSERBa29YWUlsSDkuY3lzVDAK
kind: Secret kind: Secret
metadata: metadata:
name: basic-auth name: basic-auth

View file

@ -152,7 +152,7 @@ func (a auth) Parse(ing *extensions.Ingress) (interface{}, error) {
// dumpSecret dumps the content of a secret into a file // dumpSecret dumps the content of a secret into a file
// in the expected format for the specified authorization // in the expected format for the specified authorization
func dumpSecret(filename string, secret *api.Secret) error { func dumpSecret(filename string, secret *api.Secret) error {
val, ok := secret.Data["auth"] val, ok := secret.Data["kube-ingress-auth"]
if !ok { if !ok {
return ing_errors.LocationDenied{ return ing_errors.LocationDenied{
Reason: errors.Errorf("the secret %v does not contain a key with value auth", secret.Name), Reason: errors.Errorf("the secret %v does not contain a key with value auth", secret.Name),

View file

@ -79,7 +79,7 @@ func (m mockSecret) GetSecret(name string) (*api.Secret, error) {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
Name: "demo-secret", Name: "demo-secret",
}, },
Data: map[string][]byte{"auth": []byte("foo:$apr1$OFG3Xybp$ckL0FHDAkoXYIlH9.cysT0")}, Data: map[string][]byte{"kube-ingress-auth": []byte("foo:$apr1$OFG3Xybp$ckL0FHDAkoXYIlH9.cysT0")},
}, nil }, nil
} }