|
| 1 | +package v2alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + commonapi "github.com/openmcp-project/openmcp-operator/api/common" |
| 5 | +) |
| 6 | + |
| 7 | +// AuthenticationConfiguration contains the configuration for the enabled OpenID Connect identity providers |
| 8 | +type AuthenticationConfiguration struct { |
| 9 | + // +kubebuilder:validation:Optional |
| 10 | + EnableSystemIdentityProvider *bool `json:"enableSystemIdentityProvider"` |
| 11 | + // +kubebuilder:validation:Optional |
| 12 | + IdentityProviders []IdentityProvider `json:"identityProviders,omitempty"` |
| 13 | +} |
| 14 | + |
| 15 | +// IdentityProvider contains the configuration for an OpenID Connect identity provider |
| 16 | +type IdentityProvider struct { |
| 17 | + // Name is the name of the identity provider. |
| 18 | + // The name must be unique among all identity providers. |
| 19 | + // The name must only contain lowercase letters. |
| 20 | + // The length must not exceed 63 characters. |
| 21 | + // +kubebuilder:validation:Required |
| 22 | + // +kubebuilder:validation:MaxLength=63 |
| 23 | + // +kubebuilder:validation:Pattern=`^[a-z]+$` |
| 24 | + Name string `json:"name"` |
| 25 | + // IssuerURL is the issuer URL of the identity provider. |
| 26 | + // +kubebuilder:validation:Required |
| 27 | + IssuerURL string `json:"issuerURL"` |
| 28 | + // ClientID is the client ID of the identity provider. |
| 29 | + // +kubebuilder:validation:Required |
| 30 | + ClientID string `json:"clientID"` |
| 31 | + // UsernameClaim is the claim that contains the username. |
| 32 | + // +kubebuilder:validation:Required |
| 33 | + UsernameClaim string `json:"usernameClaim"` |
| 34 | + // GroupsClaim is the claim that contains the groups. |
| 35 | + // +kubebuilder:validation:Optional |
| 36 | + GroupsClaim string `json:"groupsClaim"` |
| 37 | + // CABundle: When set, the OpenID server's certificate will be verified by one of the authorities in the bundle. |
| 38 | + // Otherwise, the host's root CA set will be used. |
| 39 | + // +kubebuilder:validation:Optional |
| 40 | + CABundle string `json:"caBundle,omitempty"` |
| 41 | + // SigningAlgs is the list of allowed JOSE asymmetric signing algorithms. |
| 42 | + // +kubebuilder:validation:Optional |
| 43 | + SigningAlgs []string `json:"signingAlgs,omitempty"` |
| 44 | + // RequiredClaims is a map of required claims. If set, the identity provider must provide these claims in the ID token. |
| 45 | + // +kubebuilder:validation:Optional |
| 46 | + RequiredClaims map[string]string `json:"requiredClaims,omitempty"` |
| 47 | + |
| 48 | + // ClientAuthentication contains configuration for OIDC clients |
| 49 | + // +kubebuilder:validation:Optional |
| 50 | + ClientConfig ClientAuthenticationConfig `json:"clientConfig,omitempty"` |
| 51 | +} |
| 52 | + |
| 53 | +// ClientAuthenticationConfig contains configuration for OIDC clients |
| 54 | +type ClientAuthenticationConfig struct { |
| 55 | + // ClientSecret is a references to a secret containing the client secret. |
| 56 | + // The client secret will be added to the generated kubeconfig with the "--oidc-client-secret" flag. |
| 57 | + // +kubebuilder:validation:Optional |
| 58 | + ClientSecret *commonapi.LocalSecretReference `json:"clientSecret,omitempty"` |
| 59 | + // ExtraConfig is added to the client configuration in the kubeconfig. |
| 60 | + // Can either be a single string value, a list of string values or no value. |
| 61 | + // Must not contain any of the following keys: |
| 62 | + // - "client-id" |
| 63 | + // - "client-secret" |
| 64 | + // - "issuer-url" |
| 65 | + // |
| 66 | + // +kubebuilder:validation:Optional |
| 67 | + ExtraConfig map[string]SingleOrMultiStringValue `json:"extraConfig,omitempty"` |
| 68 | +} |
| 69 | + |
| 70 | +// SingleOrMultiStringValue is a type that can hold either a single string value or a list of string values. |
| 71 | +type SingleOrMultiStringValue struct { |
| 72 | + // Value is a single string value. |
| 73 | + Value string `json:"value,omitempty"` |
| 74 | + // Values is a list of string values. |
| 75 | + Values []string `json:"values,omitempty"` |
| 76 | +} |
0 commit comments