-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support configuring basic auth credentials as a map of user/password hashes #4560
Conversation
Hi @actgardner. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @ElvinEfendi |
/ok-to-test |
Codecov Report
@@ Coverage Diff @@
## master #4560 +/- ##
========================================
Coverage ? 59.4%
========================================
Files ? 89
Lines ? 6848
Branches ? 0
========================================
Hits ? 4068
Misses ? 2344
Partials ? 436
Continue to review full report at Codecov.
|
/approve |
Why is |
Yes, we cannot break the current behavior.
While I agree with your comment, I prefer to be explicit about what is supported and the expected format and no some magic we code. Edit: also, you could use |
yes, but then the value would not be in the format of |
/lgtm Maybe in the next release we can just delete support for |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: actgardner, aledbf, ElvinEfendi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@actgardner hey, I used kustomize to create the secret, added the new
Generated secret appears to be correct (doing base64 decode on the value matches):
From ingress logs I can see that the password is incorrect: Any ideas what am I missing? P.S. Would be nice if examples here could be updated: https://kubernetes.github.io/ingress-nginx/examples/auth/basic/ |
@actgardner ohhh... I think got it. The password value still has to be set to the encrypted password generated by htpasswd. When creating the secret with encrypted password of htpasswd it works.
Hmm. From this I understood that everything relating to htpasswd file will be taken care for us thus we could create a secret from literals (like in my previous comment) and be done with it. In reality however I still would need to generate the htpasswd file locally, copy the password and create a secret with it. |
@rihardssceredins You can also generate the password hash by shelling out to something like |
What this PR does / why we need it:
Currently to configure basic auth a user creates a new secret and sets the
auth
key to the entire contents of an htpasswd file.In our environment we manage secrets with asymmetric encryption, where users can create new key-value pairs in secrets or replace existing values, but not read existing secrets. This makes it very cumbersome to add a new entry to the
auth
secret, because it requires fetching the entire unencrypted contents and modifying it.This PR adds an annotation
nginx.ingress.kubernetes.io/auth-secret-type
, which can have the valueauth-file
(the default, current behaviour) orauth-map
. If theauth-secret-type
is set toauth-map
, we generate an htpasswd file using all the key-value pairs in theauth-secret
. For example: