Zeabur Identity architecture
Learn how Zeabur Identity works in a Kubernetes cluster, its security properties, how its components interact, and how its crates divide responsibilities.
Zeabur Identity is an OpenID Connect Issuer that runs in a self-managed Kubernetes cluster. kube-apiserver uses Structured Authentication Configuration to verify Zeabur Identity's tokens itself. You can sign in with a passkey, an upstream account or a password, without holding a long-lived admin kubeconfig that can't be revoked. Other OpenID Connect clients, such as Argo CD, Grafana, and Headlamp, can use the same Issuer.
k3s and RKE2 use the same configuration. CI tests cover k3s.
Security properties
Section titled “Security properties”- Passkeys first. Passkeys are the primary credentials. They use WebAuthn and require user verification. Users can also sign in with a password of at least 15 characters, or link an account from GitHub, Google or another OpenID provider.
- Only admin accounts receive admin privileges. Only a
UserwithaccountType: Adminreceives thezeabur:adminsgroup, which is bound tocluster-admin. Theadmin-sign-insetting decides how admin accounts sign in. By default, they use a passkey, or a password and an authenticator code. The setting can also require a passkey, or a device-bound passkey. Admin tokens expire after five minutes by default, and inactivity can end their sessions earlier. Regular accounts receive only the permissions bound to their groups. All sessions end 12 hours after sign-in. - Tokens are short-lived. They are bound to an audience, and signing keys rotate regularly.
- Users manage their own sign-in methods. Adding or removing a passkey, or linking or unlinking an upstream account, requires the user to authenticate again with a passkey. Changing or removing a password requires the current password. Users can't remove their last passkey or unlink their last sign-in method.
- Kubernetes stores the state. Custom resources store users, credentials, clients, sessions, and invitations. No database is required. For the order of access revocation and data deletion, see Sign out, recover, and remove users.
Specification conformance lists the specification requirements Zeabur Identity implements, along with the corresponding code and verification tests.
How the components work together
Section titled “How the components work together”browser ──passkey──▶ zeabur-identity (in the cluster) ──tokens──▶ kubectl / OIDC clients │ ▲ │ custom resources bearer token ▼ │ ▼ kube-apiserver ◀──discovery + keys (internal TLS)── verifies tokens itselfA kubectl request follows these steps.
Open the sign-in page
Section titled “Open the sign-in page”kubelogin opens the browser to the Zeabur Identity sign-in page.
Sign in with a passkey
Section titled “Sign in with a passkey”The user signs in with a passkey. kubelogin receives a short-lived access token and a refresh token, and Zeabur Identity records the session in a Grant object.
Send the token
Section titled “Send the token”kubectl sends the token to kube-apiserver.
Verify the token
Section titled “Verify the token”kube-apiserver verifies the token's signature with the keys Zeabur Identity publishes. It retrieves the keys over an internal TLS connection. Zeabur Identity doesn't participate in the request itself.
Refresh an expired token
Section titled “Refresh an expired token”When the token expires, kubelogin uses the refresh token to obtain a new token without opening the browser.
The admin tool zeabur-identityctl runs on the administrator's computer with the administrator's own kubeconfig. It outputs installation manifests, generates a kube-apiserver AuthenticationConfiguration for the Kubernetes distribution, and issues one-time links for users to register passkeys.
Crate responsibilities
Section titled “Crate responsibilities”The code is split into small crates, all at the same level in the crates/ directory:
- Dependencies point downward and form no cycles. See Kladov, as well as Lakos and Martin in the references below.
- Each crate encapsulates one design decision behind a narrow interface. See Parnas.
- A set of traits defines the storage layer. Separate in-memory and Kubernetes implementations mean most tests don't need a cluster. This follows the ports and adapters architecture; see Cockburn.
- The server and admin CLI use separate executables. Kanidm (
kanidmd/kanidm), etcd (etcd/etcdctl), and cert-manager (cmctl) use the same division of responsibilities. Code that only administrators need to run stays out of the server image.
Each crate's README is also its crate-level documentation. Open it with cargo doc --open.
| Crate | What it holds | Depends on |
|---|---|---|
zeabur-identity-api | the identity.zeabur.com custom resources and the names other programs share with Zeabur Identity | — |
zeabur-identity-core | time, cryptographic helpers, validated config values, endpoint paths, password, authenticator code and guessing-limit rules | — |
zeabur-identity-keys | signing keys, JWK publication, JWS signing and verification, rotation | api, core |
zeabur-identity-store | storage ports (traits, records) and in-memory adapters | api, core, keys |
zeabur-identity-tls | trust roots, certificate issuance, a reloadable TLS listener | — |
zeabur-identity-ui | server-rendered pages, embedded assets, translations, security headers | core |
zeabur-identity-oauth | the OAuth 2.0 / OpenID Connect authorization server | api, core, keys, store, ui |
zeabur-identity-signin | passkey enrollment and sign-in, password and authenticator-code sign-in, upstream providers, page routes | api, core, keys, store, oauth, ui |
zeabur-identity-k8s | Kubernetes adapters, GC, manifests, kube-apiserver config | api, core, keys, store, tls |
zeabur-identity | binary: the in-cluster server | api, core, keys, store, tls, oauth, signin, k8s |
zeabur-identityctl | binary: the administrator's CLI | api, core, keys, k8s |
zeabur-identity-test-support, zeabur-identity-e2e | test helpers; end-to-end tests on a cluster | — |
The sign-in page's TypeScript and Tailwind source lives in ui/ and uses the Zeabur Design System as a package. Build output and the design system's style classes are committed to crates/zeabur-identity-ui and embedded in the executable. The style classes are stored as askama macros in templates/ds.html.
Development
Section titled “Development”See CONTRIBUTING.md for development environment setup, checks, dependency policies, and cluster tests.
References
Section titled “References”- The Kubernetes Authors, "KEP-3331: Structured Authentication Configuration." https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/3331-structured-authentication-configuration
- A. Kladov, "Large Rust Workspaces," Aug. 22, 2021. https://matklad.github.io/2021/08/22/large-rust-workspaces.html
- D. L. Parnas, "On the criteria to be used in decomposing systems into modules," Commun. ACM, vol. 15, no. 12, pp. 1053–1058, Dec. 1972, doi: 10.1145/361598.361623.
- J. Lakos, Large-Scale C++ Software Design. Addison-Wesley, 1996.
- R. C. Martin, Agile Software Development, Principles, Patterns, and Practices. Prentice Hall, 2002 (the Acyclic and Stable Dependencies Principles).
- A. Cockburn, "The Hexagonal (Ports & Adapters) Architecture," 2005. https://alistair.cockburn.us/hexagonal-architecture/