-
Notifications
You must be signed in to change notification settings - Fork 2k
HTTP basic auth support #2269
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
Merged
Merged
HTTP basic auth support #2269
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b650d0
add support for HTTP basic authentication policy
svvac 3d54dc2
add support for HTTP Basic authentication ingress annotations
svvac 013a938
add integration tests for HTTP basic authentication policy
6f3e363
add integration tests for HTTP Basic authentication ingress annotations
c7c1723
add documentation for HTTP Basic authentication policy support
svvac 6416a37
add documentation fo HTTP Basic authentication ingress annotations su…
svvac cd13826
Merge branch 'main' into http-basic-auth-support
lucacome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Support for HTTP Basic Authentication | ||
|
||
NGINX supports authenticating requests with [ngx_http_auth_basic_module](https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html). | ||
|
||
The Ingress controller provides the following 2 annotations for configuring Basic Auth validation: | ||
|
||
* Required: ```nginx.org/basic-auth-secret: "secret"``` -- specifies a Secret resource with a htpasswd user list. The htpasswd must be stored in the `htpasswd` data field. The type of the secret must be `nginx.org/htpasswd`. | ||
* Optional: ```nginx.org/basic-auth-realm: "realm"``` -- specifies a realm. | ||
|
||
``` | ||
|
||
## Example 1: The Same Htpasswd for All Paths | ||
|
||
In the following example we enable HTTP Basic authentication for the cafe-ingress Ingress for all paths using the same htpasswd `cafe-htpasswd`: | ||
```yaml | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: cafe-ingress | ||
annotations: | ||
nginx.org/basic-auth-secret: "cafe-passwd" | ||
nginx.org/basic-auth-realm: "Cafe App" | ||
spec: | ||
tls: | ||
- hosts: | ||
- cafe.example.com | ||
secretName: cafe-secret | ||
rules: | ||
- host: cafe.example.com | ||
http: | ||
paths: | ||
- path: /tea | ||
backend: | ||
service: | ||
name: tea-svc | ||
port: | ||
number: 80 | ||
- path: /coffee | ||
backend: | ||
service: | ||
name: coffee-svc | ||
port: | ||
number: 80 | ||
``` | ||
* The keys must be deployed separately in the Secret `cafe-jwk`. | ||
* The realm is `Cafe App`. | ||
|
||
## Example 2: a Separate Htpasswd Per Path | ||
|
||
In the following example we enable Basic Auth validation for the [mergeable Ingresses](../mergeable-ingress-types) with a separate Basic Auth user:password list per path: | ||
|
||
* Master: | ||
```yaml | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: cafe-ingress-master | ||
annotations: | ||
kubernetes.io/ingress.class: "nginx" | ||
nginx.org/mergeable-ingress-type: "master" | ||
spec: | ||
tls: | ||
- hosts: | ||
- cafe.example.com | ||
secretName: cafe-secret | ||
rules: | ||
- host: cafe.example.com | ||
``` | ||
|
||
* Tea minion: | ||
```yaml | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: cafe-ingress-tea-minion | ||
annotations: | ||
nginx.org/mergeable-ingress-type: "minion" | ||
nginx.org/basic-auth-secret: "tea-passwd" | ||
nginx.org/basic-auth-realm: "Tea" | ||
spec: | ||
rules: | ||
- host: cafe.example.com | ||
http: | ||
paths: | ||
- path: /tea | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: tea-svc | ||
port: | ||
number: 80 | ||
``` | ||
|
||
* Coffee minion: | ||
```yaml | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: cafe-ingress-coffee-minion | ||
annotations: | ||
nginx.org/mergeable-ingress-type: "minion" | ||
nginx.org/basic-auth-secret: "coffee-passwd" | ||
nginx.org/basic-auth-realm: "Coffee" | ||
spec: | ||
rules: | ||
- host: cafe.example.com | ||
http: | ||
paths: | ||
- path: /coffee | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: coffee-svc | ||
port: | ||
number: 80 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.