-
Notifications
You must be signed in to change notification settings - Fork 2k
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
HTTP basic auth support #2269
HTTP basic auth support #2269
Conversation
First draft to get the discussion going regarding naming, etc. Will add tests and docs. |
Codecov Report
@@ Coverage Diff @@
## main #2269 +/- ##
==========================================
- Coverage 53.63% 53.43% -0.21%
==========================================
Files 52 52
Lines 14842 14871 +29
==========================================
- Hits 7961 7946 -15
- Misses 6617 6657 +40
- Partials 264 268 +4
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
aef566b
to
b7b50f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @svvac
Thanks for the pull request! This is a great addition to the Ingress Controller.
I left a few comments, questions and suggestions. As you mentioned, let's finalize the requirements first, this review doesn't include comments about missing tests, etc.
internal/k8s/secrets/validation.go
Outdated
@@ -28,6 +31,9 @@ const SecretTypeJWK api_v1.SecretType = "nginx.org/jwk" | |||
// SecretTypeOIDC contains an OIDC client secret for use in oauth flows. #nosec G101 | |||
const SecretTypeOIDC api_v1.SecretType = "nginx.org/oidc" | |||
|
|||
// SecretTypeHtpasswd contains an htpasswd file for use in HTTP Basic authorization.. #nosec G101 | |||
const SecretTypeHtpasswd api_v1.SecretType = "nginx.org/htpasswd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we creating a new secret type nginx.org/htpasswd
instead of using kubernetes.io/basic-auth
standard type (https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret), because that type is limited to one user/pass combination?
cc @brianehlert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's the idea. I considered using keys of the secret as usernames and their value as auth string, but this would add processing and the user wouldn't be able to use existing passwd databases with e.g. comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought here is the experience of creating the htpasswd file and how that feels bespoke to a Kubernetes (yaml focused) operator.
I understand the choice though. The file is both native to NGINX configuration and not unusual in itself in the full context.
Documentation might help me here - walking through defining, generating, and using the htpasswd as part of the configuration.
We have tutorials or examples that could be used for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a gosec linting error, but it's a false positive. We need to skip the error similar to other places.
const SecretTypeHtpasswd api_v1.SecretType = "nginx.org/htpasswd" | |
const SecretTypeHtpasswd api_v1.SecretType = "nginx.org/htpasswd" // #nosec G101 |
ee70870
to
4d218b2
Compare
I've made the requested changes and I'll start working on the tests. |
4d218b2
to
53445c9
Compare
dede2c5
to
d0442a5
Compare
4a334bc
to
932ae89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @svvac - apologies again for the delay. I'm pulling down your code here to run through the example myself, but this overall looks great! I've a couple of minor comments, and there are some merge conflicts that need to be addressed, but otherwise this is definitely nearly there!
Thank you so much for all the work so far, and for your patience.
452190a
to
6416a37
Compare
@ciarams87 Good news then! I pushed a rebased version against |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 LGTM!! Thanks again!!
Hello, could you consider changing the secet resource requirement so that it would be possible to use the same secret for both Kubernetes ingress controller as well as for this one? Their secret looks like the following example: https://kubernetes.github.io/ingress-nginx/examples/auth/basic/#examine-secret
It would make things easier. |
Since this PR was merged approximately 9 months ago. Would you consider adding this request to Issues as a proposal? |
Sure, I just didn't want to open a new issue not knowing if this proposal would be declined anyway. |
Proposed changes
Add support for HTTP Basic authentication to Policy objects and to Ingresses via annotations.
#200 #1872
Checklist
Before creating a PR, run through this checklist and mark each as complete.