Skip to content

Conversation

@tkircsi
Copy link
Contributor

@tkircsi tkircsi commented Jan 13, 2026

Implements a production-ready Envoy ExtAuthz solution for authenticating dirctl users via GitHub OAuth2 while maintaining SPIFFE mTLS for service-to-service communication.

New Components

Authentication Provider Framework

  • Add generic provider interface in auth/authprovider/
  • Implement GitHub OAuth2 provider using github.com/google/go-github/v50
  • Support for token validation, caching (5min TTL), and org membership checks
  • Extensible design for future providers

Envoy ExtAuthz Service

  • Add auth/authzserver/ implementing Envoy ext_authz gRPC API (v3)
  • Provider auto-detection from token format (GitHub only for now)
  • Support for allowlists, denylists, and org membership requirements
  • Add auth/cmd/envoy-authz/ main service with environment-based configuration

dirctl CLI Enhancements

  • Add dirctl auth login - GitHub OAuth (Device Flow default, Web Flow with --web)
  • Add dirctl auth status - Show authentication status and validate token
  • Add dirctl auth logout - Clear cached credentials
  • Update client library with OAuth flows and token caching at ~/.config/dirctl/
  • CI/CD support via --auth-token flag or DIRECTORY_CLIENT_TOKEN env var

Deployment & Infrastructure

  • Add Helm chart install/charts/envoy-authz/
  • Integrate as optional subchart in dir Helm chart (disabled by default)
  • Add Dockerfile for multi-arch builds (amd64/arm64) with distroless base
  • Add Docker Compose setup for local testing with mock backend
  • Update docker-bake.hcl for image builds
  • Update GitHub workflows for automated releases

Key Features

  • GitHub OAuth2 only: Device Flow (default, uses GitHub CLI client ID) and Web Flow
  • PAT support: Available via env var/flag for CI/CD (DIRECTORY_CLIENT_TOKEN)
  • Optional deployment: Disabled by default, opt-in via Helm values

Module Structure

New independent modules in auth/ directory:

  • auth/authprovider/ - Provider interface and GitHub implementation
  • auth/authzserver/ - ExtAuthz gRPC server
  • auth/cmd/envoy-authz/ - Main service with Dockerfile

@github-actions github-actions bot added the size/XL Denotes a PR that changes 2000+ lines label Jan 13, 2026
@tkircsi tkircsi self-assigned this Jan 13, 2026
@tkircsi tkircsi requested review from paralta and ramizpolic January 13, 2026 09:14
@tkircsi tkircsi added kind/feature Categorizes issue or PR as related to a new feature. area/dir area/cli area/helm labels Jan 13, 2026
@tkircsi tkircsi force-pushed the feat/github-auth branch 2 times, most recently from aa9ec3b to 2a4e183 Compare January 13, 2026 09:25
@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedJan 21, 2026, 1:52 PM

@tkircsi
Copy link
Contributor Author

tkircsi commented Jan 13, 2026

Test mock server for local development only. Intentionally logs HTTP headers and user input to verify Envoy ext_authz integration. Never deployed to production. Security disclaimer added to package documentation. No actual credentials logged. Dismiss alert for cmd/envoy-authz/test/mock-directory.go file only

@tkircsi tkircsi marked this pull request as ready for review January 13, 2026 13:52
@tkircsi tkircsi requested a review from a team as a code owner January 13, 2026 13:52
@codecov
Copy link

codecov bot commented Jan 14, 2026

paralta and others added 2 commits January 16, 2026 18:38
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
tkircsi and others added 7 commits January 16, 2026 18:56
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
@ramizpolic
Copy link
Member

ramizpolic commented Jan 19, 2026

@tkircsi did you manage to find any existing implementations for ext_authz service that works with OAuth2? AFAIR we discussed that we can drop the org/gh implementation for a generic one and configure the authz rules outside of the service itself but through configs

@tkircsi
Copy link
Contributor Author

tkircsi commented Jan 19, 2026

@ramizpolic I investigated whether we could replace our custom auth/ package with existing ext_authz implementations, but what I've found is production-grade ext_authz services require OIDC, not pure OAuth2. Do you have any suggestions?
GitHub only provides OAuth2 (opaque tokens), not OIDC. So, we would introduce an OIDC provider besides Envoy in our solution. This can be useful for future, but I don't think in v1.

Copy link
Member

@paralta paralta left a comment

Choose a reason for hiding this comment

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

a couple of comments on the cli changes, will continue with the other parts

tkircsi and others added 5 commits January 20, 2026 13:40
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Signed-off-by: Tibor Kircsi <tkircsi@cisco.com>
Copy link
Member

@paralta paralta left a comment

Choose a reason for hiding this comment

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

client code looks good overall 👍

However, the OAuth code (oauth_web.go, oauth_device.go, token_cache.go) talks to GitHub, not the Directory server, so I think it does not really belong in the Dir client module. I would suggest moving to auth/client.

Copy link
Member

@paralta paralta left a comment

Choose a reason for hiding this comment

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

Regarding the auth changes, the three modules under this folder (authprovider, authzserver, cmd/envoy-authz) are tightly coupled. I think it would be simpler to have a single module with subpackages, WDYT?

@tkircsi
Copy link
Contributor Author

tkircsi commented Jan 21, 2026

That's a good idea, and I agree. But let's wait for the OIDC provider PoC, because with the OIDC provider (Zitadel(or other) + Envoy) solution, the entire auth package can be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli area/dir area/helm kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants