Skip to content

Add support for HTTP External Authorization Services - #7418

Merged
tsaarni merged 5 commits into
projectcontour:mainfrom
snapp-incubator:http-ext-authz
Jun 4, 2026
Merged

Add support for HTTP External Authorization Services#7418
tsaarni merged 5 commits into
projectcontour:mainfrom
snapp-incubator:http-ext-authz

Conversation

@therealak12

@therealak12 therealak12 commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

Envoy external authorization filter supports HTTP and GRPC servers. Contour only supports configuring gRPC services at the moment. The PR adds support for HTTP ext-authz services.

We've been using this in production for >1 year.

  1. feat: add http support to authz filter snapp-incubator/contour#4
  2. refactor: add http auth support to contour snapp-incubator/contour#5

Closes #6509

@therealak12
therealak12 requested a review from a team as a code owner February 14, 2026 05:57
@therealak12
therealak12 requested review from sunjayBhatia and tsaarni and removed request for a team February 14, 2026 05:57
@sunjayBhatia
sunjayBhatia requested review from a team, davinci26 and wilsonwu and removed request for a team February 14, 2026 05:57
Signed-off-by: therealak12 <ak12hastam@gmail.com>
@tsaarni tsaarni added the release-note/minor A minor change that needs about a paragraph of explanation in the release notes. label Feb 14, 2026
@codecov

codecov Bot commented Feb 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.31034% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.32%. Comparing base (9477aaf) to head (b53f49d).
⚠️ Report is 111 commits behind head on main.

Files with missing lines Patch % Lines
internal/envoy/v3/listener.go 77.61% 15 Missing ⚠️
cmd/contour/serve.go 0.00% 9 Missing ⚠️
internal/dag/httpproxy_processor.go 89.65% 6 Missing ⚠️
internal/dag/conditions.go 75.00% 2 Missing and 2 partials ⚠️
cmd/contour/servecontext.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7418      +/-   ##
==========================================
+ Coverage   81.85%   82.32%   +0.47%     
==========================================
  Files         130      130              
  Lines       15747    15789      +42     
==========================================
+ Hits        12889    12998     +109     
+ Misses       2574     2505      -69     
- Partials      284      286       +2     
Files with missing lines Coverage Δ
internal/dag/dag.go 98.44% <ø> (ø)
internal/envoy/v3/cluster.go 96.24% <100.00%> (+0.03%) ⬆️
internal/featuretests/v3/envoy.go 99.36% <100.00%> (+0.01%) ⬆️
internal/xdscache/v3/listener.go 92.09% <100.00%> (+0.16%) ⬆️
pkg/config/parameters.go 87.10% <ø> (ø)
cmd/contour/servecontext.go 86.56% <33.33%> (-0.07%) ⬇️
internal/dag/conditions.go 96.29% <75.00%> (-1.35%) ⬇️
internal/dag/httpproxy_processor.go 91.26% <89.65%> (-0.18%) ⬇️
cmd/contour/serve.go 24.01% <0.00%> (+0.40%) ⬆️
internal/envoy/v3/listener.go 95.89% <77.61%> (-2.28%) ⬇️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tsaarni tsaarni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @therealak12 for the contribution!

The changes look good overall but I would like to discuss some of the API aspects and potential error scenarios.

Comment thread pkg/config/parameters.go Outdated
Comment thread pkg/config/parameters.go Outdated
// HttpAuthorizationServerSettings defines configurations for interacting with an external HTTP authorization server.
//
// +optional
HTTPServerSettings *contour_v1.HTTPAuthorizationServerSettings `json:"httpSettings,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config file is parsed as YAML

Suggested change
HTTPServerSettings *contour_v1.HTTPAuthorizationServerSettings `json:"httpSettings,omitempty"`
HTTPServerSettings *contour_v1.HTTPAuthorizationServerSettings `yaml:"httpSettings,omitempty"`

Comment thread internal/featuretests/v3/authorization_test.go Outdated
Comment thread internal/envoy/v3/listener.go
Comment thread apis/projectcontour/v1/httpproxy.go
Comment thread cmd/contour/serve.go Outdated
Comment on lines +839 to +841
switch contourConfiguration.GlobalExternalAuthorization.ServiceAPIType {
case contour_v1.AuthorizationGRPCService:
globalExternalAuthConfig.ServiceAPIType = contour_v1.AuthorizationGRPCService

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have fall back to the gRPC authorization server type here if type is not set?

Comment thread cmd/contour/serve.go Outdated
Comment thread internal/dag/httpproxy_processor.go Outdated
AuthorizationResponseTimeout: *respTimeout,
}

switch auth.ServiceAPIType {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should refactor the switch-case logic in internal/dag/httpproxy_processor.go within computeVirtualHostAuthorization() and the corresponding logic in cmd/contour/serve.go within setupGlobalExternalAuthentication() into one.

Comment thread internal/featuretests/v3/authorization_test.go Outdated
Comment thread apis/projectcontour/v1/httpproxy.go Outdated
Comment thread internal/envoy/v3/listener.go Outdated
@tsaarni

tsaarni commented Feb 27, 2026

Copy link
Copy Markdown
Member

@therealak12 I did some experiments related to my previous comments. You are free to use any of this work: snapp-incubator/contour@http-ext-authz...Nordix:contour:http-based-ext-authz

@github-actions

Copy link
Copy Markdown

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 30d of inactivity, lifecycle/stale is applied
  • After 60d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Ensure your PR is passing all CI checks. PRs that are fully green are more likely to be reviewed. If you are having trouble with CI checks, reach out to the #contour channel in the Kubernetes Slack workspace.
  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 11, 2026
Signed-off-by: therealak12 <ak12hastam@gmail.com>
@therealak12

Copy link
Copy Markdown
Contributor Author

Hi, thank you for your review and the helpful suggestions.

Apologies for the delay. Due to the recent war affecting my country, I was unable to continue working on this PR for some time. Now that the situation has stabilized, I applied the requested changes.

Please take another look when you have a chance.

@github-actions github-actions Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 12, 2026
@therealak12

therealak12 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

@tsaarni Does this code compile? I've picked all of the changes and applied them to the current branch, but the NewExternalAuthorization function is not defined.

I would appreciate if you could help me find the definition of NewExternalAuthorization.

@github-actions

Copy link
Copy Markdown

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 30d of inactivity, lifecycle/stale is applied
  • After 60d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Ensure your PR is passing all CI checks. PRs that are fully green are more likely to be reviewed. If you are having trouble with CI checks, reach out to the #contour channel in the Kubernetes Slack workspace.
  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 27, 2026
@therealak12

Copy link
Copy Markdown
Contributor Author

/remove-lifecycle-stale

@tsaarni tsaarni removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 30, 2026
…imeout and its tests

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@tsaarni

tsaarni commented Jun 2, 2026

Copy link
Copy Markdown
Member

@tsaarni Does this code compile? I've picked all of the changes and applied them to the current branch, but the NewExternalAuthorization function is not defined.

Hi @therealak12, You are right, sorry it was broken. I have now re-implemented it and pushed update here Nordix@19757e6.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@therealak12

Copy link
Copy Markdown
Contributor Author

Hi @therealak12, You are right, sorry it was broken. I have now re-implemented it and pushed update here Nordix@19757e6.

Thanks. I've pushed your commits to our branch as-is. Meanwhile, I'm reviewing the rest of the PR to ensure all the changes are aligned with the original intent.

@tsaarni

tsaarni commented Jun 3, 2026

Copy link
Copy Markdown
Member

Thanks @therealak12!

By the way, the e2e test case is something I was experimenting yesterday as I thought e2e coverage would be good, because this functionality is quite sensitive.

Previously, we tested the gRPC-based external authorization using a separate server image deployed on a Kind cluster. However, I think it would be unnecessarily complicated to introduce that. Instead we can configure Envoy to connect to the host via a Service and EndpointSlice, and then set up an HTTP server as part of e2e test suite, giving the test case full control to run assertions.

image

@therealak12

Copy link
Copy Markdown
Contributor Author

I reviewed the code. The local http-server idea is cool. I pushed the e2e test commit again.
@tsaarni

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@tsaarni

tsaarni commented Jun 4, 2026

Copy link
Copy Markdown
Member

Hi @therealak12, could you still apply this formatting fix Nordix@b53f49d
Thanks!

@therealak12

therealak12 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Hi @therealak12, could you still apply this formatting fix Nordix@b53f49d Thanks!

Hi. Done. Sorry, I must have already done that.

@therealak12

Copy link
Copy Markdown
Contributor Author

Please feel free to make any changes to this code as you see fit. I'll also check my email more frequently to take any necessary actions.
@tsaarni

@tsaarni tsaarni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank You for contributing @therealak12 !

@tsaarni
tsaarni merged commit 77c3f77 into projectcontour:main Jun 4, 2026
41 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/minor A minor change that needs about a paragraph of explanation in the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for HTTP based external auth server

2 participants