Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
34ab1b5
feat: migraet machineAccountKey from IAM APIGroup to Identity APIGroup
JoseSzycho Mar 25, 2026
28f5da4
feat: implement MachineAccountKey RESTStorage and e2e tests
JoseSzycho Mar 25, 2026
1092e15
feat: implement protected resources and roles for machineAccount and …
JoseSzycho Mar 25, 2026
c95dd44
fix: add missing Kustomize component to generate identity resource me…
JoseSzycho Mar 25, 2026
95150cd
refactor: Enforce MachineAccountKey spec immutability and remove cust…
JoseSzycho Mar 25, 2026
9be63c0
chore: add missing newlines at end of files
github-actions[bot] Mar 28, 2026
c022b90
refactor: rename MachineAccountName to MachineAccountUserName in Mach…
JoseSzycho Mar 31, 2026
0c81ac9
refactor: decouple machine account key storage from etcd by introduci…
JoseSzycho Mar 31, 2026
1f18683
chore: format code
JoseSzycho Mar 31, 2026
6d9ce04
chore: remove obsolete machine-account-key-creation chainsaw tests
JoseSzycho Mar 31, 2026
db471ce
feat: add identity-machine-account-keys-admin role to project-admin c…
JoseSzycho Mar 31, 2026
a552f5e
feat: add project key to forward-extras configuration
JoseSzycho Apr 1, 2026
2574c6f
feat: add field selector support for MachineAccountKey
JoseSzycho Apr 1, 2026
6f66381
Revert "feat: add project key to forward-extras configuration"
JoseSzycho Apr 1, 2026
17b74e7
Revert "feat: add identity-machine-account-keys-admin role to project…
JoseSzycho Apr 1, 2026
012ff56
chore: autogenerate code
JoseSzycho Apr 1, 2026
9552777
Merge branch 'main' into 670-ma-api
scotwells Apr 1, 2026
0a99897
docs: add MachineAccountKey resource documentation and update table f…
JoseSzycho Apr 1, 2026
7bf5774
feat: disable MachineAccountKeys feature gate by default
JoseSzycho Apr 1, 2026
6f02eac
feat: configure audit policy to redact MachineAccountKey private keys…
JoseSzycho Apr 1, 2026
1f72354
feat: change MachineAccount CRD scope from Namespaced to Cluster
JoseSzycho Apr 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions cmd/milo/apiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (

"go.miloapis.com/milo/internal/apiserver/admission/initializer"
eventsbackend "go.miloapis.com/milo/internal/apiserver/events"
machineaccountkeysbackend "go.miloapis.com/milo/internal/apiserver/identity/machineaccountkeys"
sessionsbackend "go.miloapis.com/milo/internal/apiserver/identity/sessions"
useridentitiesbackend "go.miloapis.com/milo/internal/apiserver/identity/useridentities"
identitystorage "go.miloapis.com/milo/internal/apiserver/storage/identity"
Expand All @@ -69,9 +70,10 @@ type Config struct {
}

type ExtraConfig struct {
SessionsProvider SessionsProviderConfig
UserIdentitiesProvider UserIdentitiesProviderConfig
EventsProvider EventsProviderConfig
SessionsProvider SessionsProviderConfig
UserIdentitiesProvider UserIdentitiesProviderConfig
MachineAccountKeysProvider MachineAccountKeysProviderConfig
EventsProvider EventsProviderConfig
}

// SessionsProviderConfig groups configuration for the sessions backend provider
Expand Down Expand Up @@ -107,6 +109,17 @@ type EventsProviderConfig struct {
ForwardExtras []string
}

// MachineAccountKeysProviderConfig groups configuration for the machineaccountkeys backend provider
type MachineAccountKeysProviderConfig struct {
URL string
CAFile string
ClientCertFile string
ClientKeyFile string
TimeoutSeconds int
Retries int
ForwardExtras []string
}

type completedConfig struct {
Options options.CompletedOptions

Expand Down Expand Up @@ -149,9 +162,7 @@ func (c *CompletedConfig) GenericStorageProviders(discovery discovery.DiscoveryI
discoveryrest.StorageProvider{},
}

if utilfeature.DefaultFeatureGate.Enabled(features.Sessions) || utilfeature.DefaultFeatureGate.Enabled(features.UserIdentities) {
providers = append(providers, newIdentityStorageProvider(c))
}
providers = append(providers, newIdentityStorageProvider(c))

if utilfeature.DefaultFeatureGate.Enabled(features.EventsProxy) {
providers = append(providers, newEventsV1StorageProvider(eventsBackend))
Expand Down Expand Up @@ -201,6 +212,25 @@ func newIdentityStorageProvider(c *CompletedConfig) controlplaneapiserver.RESTSt
provider.UserIdentities = backend
}

if utilfeature.DefaultFeatureGate.Enabled(features.MachineAccountKeys) {
allow := make(map[string]struct{}, len(c.ExtraConfig.MachineAccountKeysProvider.ForwardExtras))
for _, k := range c.ExtraConfig.MachineAccountKeysProvider.ForwardExtras {
allow[k] = struct{}{}
}
cfg := machineaccountkeysbackend.Config{
BaseConfig: c.ControlPlane.Generic.LoopbackClientConfig,
ProviderURL: c.ExtraConfig.MachineAccountKeysProvider.URL,
CAFile: c.ExtraConfig.MachineAccountKeysProvider.CAFile,
ClientCertFile: c.ExtraConfig.MachineAccountKeysProvider.ClientCertFile,
ClientKeyFile: c.ExtraConfig.MachineAccountKeysProvider.ClientKeyFile,
Timeout: time.Duration(c.ExtraConfig.MachineAccountKeysProvider.TimeoutSeconds) * time.Second,
Retries: c.ExtraConfig.MachineAccountKeysProvider.Retries,
ExtrasAllow: allow,
}
backend, _ := machineaccountkeysbackend.NewDynamicProvider(cfg)
provider.MachineAccountKeys = backend
}

return provider
}

Expand Down
54 changes: 35 additions & 19 deletions cmd/milo/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,29 @@ func init() {
}

var (
SystemNamespace string
sessionsProviderURL string
sessionsProviderCAFile string
sessionsProviderClientCert string
sessionsProviderClientKey string
providerTimeoutSeconds int
providerRetries int
forwardExtras []string
userIdentitiesProviderURL string
userIdentitiesProviderCAFile string
userIdentitiesProviderClientCert string
userIdentitiesProviderClientKey string
eventsProviderURL string
eventsProviderCAFile string
eventsProviderClientCert string
eventsProviderClientKey string
eventsProviderTimeoutSeconds int
eventsProviderRetries int
eventsForwardExtras []string
SystemNamespace string
sessionsProviderURL string
sessionsProviderCAFile string
sessionsProviderClientCert string
sessionsProviderClientKey string
providerTimeoutSeconds int
providerRetries int
forwardExtras []string
userIdentitiesProviderURL string
userIdentitiesProviderCAFile string
userIdentitiesProviderClientCert string
userIdentitiesProviderClientKey string
machineAccountKeysProviderURL string
machineAccountKeysProviderCAFile string
machineAccountKeysProviderClientCert string
machineAccountKeysProviderClientKey string
eventsProviderURL string
eventsProviderCAFile string
eventsProviderClientCert string
eventsProviderClientKey string
eventsProviderTimeoutSeconds int
eventsProviderRetries int
eventsForwardExtras []string
)

// NewCommand creates a *cobra.Command object with default parameters
Expand Down Expand Up @@ -184,6 +188,10 @@ func NewCommand() *cobra.Command {
fs.StringVar(&userIdentitiesProviderCAFile, "useridentities-provider-ca-file", "", "Path to CA file to validate useridentities provider TLS")
fs.StringVar(&userIdentitiesProviderClientCert, "useridentities-provider-client-cert", "", "Client certificate for mTLS to useridentities provider")
fs.StringVar(&userIdentitiesProviderClientKey, "useridentities-provider-client-key", "", "Client private key for mTLS to useridentities provider")
fs.StringVar(&machineAccountKeysProviderURL, "machineaccountkeys-provider-url", "", "Direct provider base URL for machineaccountkeys (e.g., https://zitadel-apiserver:8443)")
fs.StringVar(&machineAccountKeysProviderCAFile, "machineaccountkeys-provider-ca-file", "", "Path to CA file to validate machineaccountkeys provider TLS")
fs.StringVar(&machineAccountKeysProviderClientCert, "machineaccountkeys-provider-client-cert", "", "Client certificate for mTLS to machineaccountkeys provider")
fs.StringVar(&machineAccountKeysProviderClientKey, "machineaccountkeys-provider-client-key", "", "Client private key for mTLS to machineaccountkeys provider")
fs.StringVar(&eventsProviderURL, "events-provider-url", "", "Activity API server URL for events storage (e.g., https://activity-apiserver.activity-system.svc:443)")
fs.StringVar(&eventsProviderCAFile, "events-provider-ca-file", "", "Path to CA file to validate Activity provider TLS")
fs.StringVar(&eventsProviderClientCert, "events-provider-client-cert", "", "Client certificate for mTLS to Activity provider")
Expand Down Expand Up @@ -253,6 +261,14 @@ func Run(ctx context.Context, opts options.CompletedOptions) error {
config.ExtraConfig.UserIdentitiesProvider.Retries = providerRetries
config.ExtraConfig.UserIdentitiesProvider.ForwardExtras = forwardExtras

config.ExtraConfig.MachineAccountKeysProvider.URL = machineAccountKeysProviderURL
config.ExtraConfig.MachineAccountKeysProvider.CAFile = machineAccountKeysProviderCAFile
config.ExtraConfig.MachineAccountKeysProvider.ClientCertFile = machineAccountKeysProviderClientCert
config.ExtraConfig.MachineAccountKeysProvider.ClientKeyFile = machineAccountKeysProviderClientKey
config.ExtraConfig.MachineAccountKeysProvider.TimeoutSeconds = providerTimeoutSeconds
config.ExtraConfig.MachineAccountKeysProvider.Retries = providerRetries
config.ExtraConfig.MachineAccountKeysProvider.ForwardExtras = forwardExtras

config.ExtraConfig.EventsProvider.URL = eventsProviderURL
config.ExtraConfig.EventsProvider.CAFile = eventsProviderCAFile
config.ExtraConfig.EventsProvider.ClientCertFile = eventsProviderClientCert
Expand Down
13 changes: 13 additions & 0 deletions config/apiserver/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ spec:
- --useridentities-provider-ca-file=$(USERIDENTITIES_PROVIDER_CA_FILE)
- --useridentities-provider-client-cert=$(USERIDENTITIES_PROVIDER_CLIENT_CERT_FILE)
- --useridentities-provider-client-key=$(USERIDENTITIES_PROVIDER_CLIENT_KEY_FILE)
# MachineAccountKeys provider configuration
- --machineaccountkeys-provider-url=$(MACHINEACCOUNTKEYS_PROVIDER_URL)
- --machineaccountkeys-provider-ca-file=$(MACHINEACCOUNTKEYS_PROVIDER_CA_FILE)
- --machineaccountkeys-provider-client-cert=$(MACHINEACCOUNTKEYS_PROVIDER_CLIENT_CERT_FILE)
- --machineaccountkeys-provider-client-key=$(MACHINEACCOUNTKEYS_PROVIDER_CLIENT_KEY_FILE)
# Events proxy provider configuration (requires EventsProxy feature gate)
- --events-provider-url=$(EVENTS_PROVIDER_URL)
- --events-provider-ca-file=$(EVENTS_PROVIDER_CA_FILE)
Expand Down Expand Up @@ -156,6 +161,14 @@ spec:
value: ""
- name: USERIDENTITIES_PROVIDER_CLIENT_KEY_FILE
value: ""
- name: MACHINEACCOUNTKEYS_PROVIDER_URL
value: ""
- name: MACHINEACCOUNTKEYS_PROVIDER_CA_FILE
value: ""
- name: MACHINEACCOUNTKEYS_PROVIDER_CLIENT_CERT_FILE
value: ""
- name: MACHINEACCOUNTKEYS_PROVIDER_CLIENT_KEY_FILE
value: ""
# Events proxy provider configuration (requires --feature-gates=EventsProxy=true)
- name: EVENTS_PROVIDER_URL
value: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ data:
- group: "" # core API group
resources: ["secrets", "configmaps"]

# Log MachineAccountKey at Metadata level to redact private key from audit logs
# The privateKey is only returned in the response body on creation, so we omit
# the response to prevent credential leakage in audit logs
- level: Metadata
resources:
- group: "identity.miloapis.com"
resources: ["machineaccountkeys"]

# Log Milo API resources at RequestResponse level to capture full context
- level: RequestResponse
resources:
Expand Down
153 changes: 0 additions & 153 deletions config/crd/bases/iam/iam.miloapis.com_machineaccountkeys.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion config/crd/bases/iam/iam.miloapis.com_machineaccounts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
listKind: MachineAccountList
plural: machineaccounts
singular: machineaccount
scope: Namespaced
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .status.email
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/iam/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
- iam.miloapis.com_machineaccounts.yaml
- iam.miloapis.com_policybindings.yaml
- iam.miloapis.com_protectedresources.yaml
- iam.miloapis.com_users.yaml
- iam.miloapis.com_userinvitations.yaml
- iam.miloapis.com_machineaccountkeys.yaml
- iam.miloapis.com_userpreferences.yaml
- iam.miloapis.com_userdeactivations.yaml
- iam.miloapis.com_platforminvitations.yaml

Check warning on line 12 in config/crd/bases/iam/kustomization.yaml

View check run for this annotation

JoggrBot / Joggr

config/crd/bases/iam/kustomization.yaml#L8-L12

"docs/api/iam.md" is outdated: MachineAccountKey CRD resource was removed from the CRDs kustomization—so it is no longer installed but the documentation hasn't changed.
- iam.miloapis.com_platformaccessapprovals.yaml
1 change: 1 addition & 0 deletions config/protected-resources/iam/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ resources:
- platformaccessapproval.yaml
- platformaccessrejection.yaml
- platforminvitation.yaml
- machineaccount.yaml

21 changes: 21 additions & 0 deletions config/protected-resources/iam/machineaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: ProtectedResource
metadata:
name: iam.miloapis.com-machineaccount
spec:
serviceRef:
name: "iam.miloapis.com"
kind: MachineAccount
plural: machineaccounts
singular: machineaccount
permissions:
- list
- get
- create
- update
- delete
- patch
- watch
parentResources:
- apiGroup: resourcemanager.miloapis.com
kind: Project
1 change: 1 addition & 0 deletions config/protected-resources/identity/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ kind: Kustomization
resources:
- session.yaml
- useridentity.yaml
- machineaccountkey.yaml
Loading
Loading