-
Notifications
You must be signed in to change notification settings - Fork 187
Add support for External Authentication for HTTPRoutes #5145
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3841113
add support for external auth
salonichf5 fbcaf05
update based on reviews
salonichf5 7536d67
simplify filter validation
salonichf5 c3ef6e5
remove mirror backend from BTP checks
salonichf5 13608f2
allow external auth server to have its own BTP, pass main location bl…
salonichf5 22cfbd6
address copilot review comments
salonichf5 e766a70
address review comments
salonichf5 4484af4
add back auth header comment
salonichf5 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # External Authentication | ||
|
|
||
| This directory contains the YAML files used in the [External Authentication](https://docs.nginx.com/nginx-gateway-fabric/traffic-security/external-authentication/) guide. |
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,52 @@ | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| name: coffee | ||
| spec: | ||
| parentRefs: | ||
| - name: gateway | ||
| sectionName: http | ||
| hostnames: | ||
| - "cafe.example.com" | ||
| rules: | ||
| - matches: | ||
| - path: | ||
| type: PathPrefix | ||
| value: /coffee | ||
| filters: | ||
| - type: ExternalAuth | ||
| externalAuth: | ||
| protocol: HTTP | ||
| backendRef: | ||
| name: ext-auth-server | ||
| port: 80 | ||
| http: | ||
| path: / | ||
| allowedHeaders: | ||
| - X-Api-Key | ||
| allowedResponseHeaders: | ||
| - X-User-Id | ||
| forwardBody: | ||
| maxSize: 1024 | ||
| backendRefs: | ||
| - name: coffee | ||
| port: 80 | ||
| --- | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| name: tea | ||
| spec: | ||
| parentRefs: | ||
| - name: gateway | ||
| sectionName: http | ||
| hostnames: | ||
| - "cafe.example.com" | ||
| rules: | ||
| - matches: | ||
| - path: | ||
| type: Exact | ||
| value: /tea | ||
| backendRefs: | ||
| - name: tea | ||
| port: 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: coffee | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: coffee | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: coffee | ||
| spec: | ||
| containers: | ||
| - name: coffee | ||
| image: nginxdemos/nginx-hello:plain-text | ||
| ports: | ||
| - containerPort: 8080 | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: coffee | ||
| spec: | ||
| ports: | ||
| - port: 80 | ||
| targetPort: 8080 | ||
| protocol: TCP | ||
| name: http | ||
| selector: | ||
| app: coffee | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: tea | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: tea | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: tea | ||
| spec: | ||
| containers: | ||
| - name: tea | ||
| image: nginxdemos/nginx-hello:plain-text | ||
| ports: | ||
| - containerPort: 8080 | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: tea | ||
| spec: | ||
| ports: | ||
| - port: 80 | ||
| targetPort: 8080 | ||
| protocol: TCP | ||
| name: http | ||
| selector: | ||
| app: tea |
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,57 @@ | ||
| # yamllint disable rule:indentation | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: ext-auth-config | ||
| data: | ||
| default.conf: | | ||
| server { | ||
| listen 8080; | ||
|
|
||
| location / { | ||
| if ($http_x_api_key != "my-custom-secret") { | ||
| return 401 "unauthorized"; | ||
| } | ||
| return 200 "ok"; | ||
| } | ||
| } | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: ext-auth-server | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: ext-auth-server | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: ext-auth-server | ||
| spec: | ||
| containers: | ||
| - name: nginx | ||
| image: nginx:latest | ||
| ports: | ||
| - containerPort: 8080 | ||
| volumeMounts: | ||
| - name: config | ||
| mountPath: /etc/nginx/conf.d | ||
| volumes: | ||
| - name: config | ||
| configMap: | ||
| name: ext-auth-config | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: ext-auth-server | ||
| spec: | ||
| ports: | ||
| - port: 80 | ||
| targetPort: 8080 | ||
| protocol: TCP | ||
| name: http | ||
| selector: | ||
| app: ext-auth-server |
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,11 @@ | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: Gateway | ||
| metadata: | ||
| name: gateway | ||
| spec: | ||
| gatewayClassName: nginx | ||
| listeners: | ||
| - name: http | ||
| port: 80 | ||
| protocol: HTTP | ||
| hostname: "*.example.com" |
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.
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.