Authentication infrastructure for Milo's business operating system backed by Zitadel - enabling secure identity management, token generation, and account lifecycle management across business entities like users, organizations, and machine accounts.
This project provides the authentication foundation for the Milo business operating system, which uses Kubernetes APIServer patterns to manage business entities for product-led B2B companies. The auth provider integrates Milo's business APIs with Zitadel's identity and access management platform to handle complex authentication scenarios like:
- "How do sales reps securely authenticate to access customer data?"
- "How can we manage machine-to-machine authentication for automated workflows?"
- "How do we handle user lifecycle management across organizational boundaries?"
- Identity Management - Centralized user authentication and identity lifecycle management for Milo resources
- Token Generation & Validation - Secure JWT token issuance and validation for API access
- Account Management - User registration, profile management, and organizational membership handling
- Machine Account Management - Automated service account creation and credential management for system integrations
- Identity Registration: Users and machine accounts are registered in Zitadel with appropriate organizational context and metadata
- Authentication Flow: The system handles OAuth2/OIDC flows for user login and machine-to-machine authentication
- Token Management: Secure JWT tokens are issued with appropriate claims and scopes based on user context and permissions
- Account Lifecycle: User onboarding, profile updates, and deactivation are managed through Zitadel's APIs
- Machine Account Provisioning: key creation and rotation for service accounts used by Milo's internal systems
- Session Management: Secure session handling with configurable token lifetimes and refresh capabilities
- Integration Bridge: Seamless integration with Milo's Kubernetes-based APIs
This repository includes a small API server that exposes Milo's identity sessions as a Kubernetes-native API under the provider group/version:
- Group/Version:
identity.milo.io/v1alpha1 - Resource:
sessions - Scope: cluster-scoped, virtual (no etcd)
- Types: reuses Milo Identity public
Sessiontypes bound to the provider G/V
- Trusts Milo's inbound request headers (X-Remote-User, X-Remote-Group, X-Remote-Uid, etc)
- Enforces self-scoping (users only see and act on their own sessions)
- Proxies list/get/delete to Zitadel Session Service v2 using the official
zitadel-go/v3SDK
Kustomize base manifests live under config/base/services/apiserver/ and are included in config/base/kustomization.yaml.
- Deployment: runs the
apiserversubcommand from this binary - Service: ClusterIP on 443 -> container 8443
Environment variables (mounted via Secret/ConfigMap as you prefer):
ZITADEL_API: e.g.<tenant>.<region>.zitadel.cloudZITADEL_ISSUER: e.g.https://<tenant>.<region>.zitadel.cloudZITADEL_KEY_PATH: path to Zitadel machine account JSON key (mounted to the container)REQUESTHEADER_CLIENT_CA_FILE: path to PEM CA bundle that signs Milo's client certREQUESTHEADER_ALLOWED_NAMES: allowed CNs for Milo client cert; empty means any signed by CAREQUESTHEADER_EXTRA_HEADERS_PREFIX: header name prefixes to determine user extra infoREQUESTHEADER_GROUP_HEADERS: header names to determine user groupsREQUESTHEADER_USERNAME_HEADERS: header names to determine user identityREQUESTHEADER_UID_HEADERS: header names to determine user UID
- The apiserver is stateless and does not use etcd
- It relies on the core apiserver for authentication and authorization
- The service user (machine account JSON key) is used to authenticate to Zitadel
Follow these steps to run the end-to-end (e2e) tests locally:
-
Create a local Kind cluster:
make kind-create
-
Run the e2e test suite:
make test-e2e
-
Inspect the controller logs once the tests have finished:
cat test/controller.log
- Create an Actions V2 target that points to the
create-user-webhookendpoint:
https://localhost:8888/v1/actions/create-user-account
- Create an Actions V2 action based on your UI type:
- Zitadel UI: Configure the event
user.human.selfregisteredwith the previously created target - Zitadel Custom UI: Configure the event
user.human.addedwith the previously created target
- Zitadel UI: Configure the event