How istio-ecosystem/authservice works
Project Type and Purpose
• The project is an external authorization service (“authservice”) that integrates with Istio and Kubernetes environments. Its primary purpose is to handle OIDC flows (i.e., the Authorization Code Grant Flow) to provide transparent login/logout, session management, and fine-grained URL protection.
Main Components
a. Client/Consumer:
• External clients or end-user applications initiating requests via a browser or API.
b. Envoy/Istio Gateway or Sidecar:
• How Envoy or Istio intercepts traffic and interacts with authservice to delegate authentication/authorization.
c. Authservice Core:
• Processing incoming auth requests.
• Invoking OIDC logic and session management.
• Inside the core, it’s helpful to decompose internal modules such as:
• internal/server – which handles HTTP endpoints (health checks, auth processing, request logging, etc.).
• internal/authz – which encapsulates the authorization logic and flows.
• internal/oidc – details functions like token handling, session management, discovery, delegation to OIDC providers, and possibly Redis integration (as seen in redis.go).
• internal/k8s – which includes controllers and secret management for Kubernetes integration.
• internal/http and logging packages – which manage HTTP layer utilities and structured logging.
d. Configuration & Protobuf Setup:
• A component that represents configuration management. Note the config directory which holds proto definitions (in config/v1), generated code under config/gen, and supporting files. This ensures that the service is highly configurable.
e. External Systems & Services:
• External OIDC Providers: Identify connections to generic OIDC providers (e.g., Keycloak is present in the e2e tests).
• Redis: As a session store, indicated by the internal/oidc/redis.go module and accompanying e2e tests.
• CI/CD and Deployment:
• Use of GitHub actions workflows (located in .github/workflows) showing a pipeline for testing, code scanning, publishing, etc.
• Docker (Dockerfile and run-in-docker.sh) for containerization.
• Deployment-oriented components in the e2e folder which include test harnesses for Istio clusters, keycloak, and mocked services.
Relationships and Interactions
• Data Flow:
• Further illustrate interactions inside core components where, for instance, the authservice invokes OIDC routines (discovery, token issuance, session refresh) and might interact with Redis for session caching.
• Dependencies:
• Bidirectional dependencies between the configuration components and the core business logic. Likewise, demonstrate how the k8s components may watch secrets or configuration changes in a cluster.
Architectural Patterns and Design Principles
• Modularity: The service is broken up into distinct internal packages (authz, oidc, server, k8s) which help enforce separation of concerns.
• Configuration-Driven: With protobufs and configuration files in the config directory, the design is strongly oriented toward a dynamically configurable system.
Final Touches
• Clarity by breaking down monolithic parts into subcomponents where relevant, especially given the extensive internal package organization.