Skip to content

Commit 5dd409f

Browse files
committed
add ManagedControlPlane type
1 parent 376d225 commit 5dd409f

File tree

3 files changed

+283
-0
lines changed

3 files changed

+283
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package v2alpha1
2+
3+
import (
4+
rbacv1 "k8s.io/api/rbac/v1"
5+
)
6+
7+
type AuthorizationConfiguration struct {
8+
// Members is a list of members with their assigned roles.
9+
Members []Member `json:"members,omitempty"`
10+
}
11+
12+
type Member struct {
13+
Subject `json:",inline"`
14+
15+
// Roles is a list of roles assigned to the subject.
16+
Roles []string `json:"roles,omitempty"`
17+
}
18+
19+
// Subject contains a reference to the object or user identities a role binding applies to. This can either hold a direct API object reference,
20+
// or a value for non-objects such as user and group names.
21+
// +kubebuilder:validation:XValidation:rule="self.kind == 'ServiceAccount' || !has(self.__namespace__)",message="Namespace must not be specified if Kind is User or Group"
22+
// +kubebuilder:validation:XValidation:rule="self.kind != 'ServiceAccount' || has(self.__namespace__)",message="Namespace is required for ServiceAccount"
23+
type Subject struct {
24+
// Kind of object being referenced. Can be "User", "Group", or "ServiceAccount".
25+
// +kubebuilder:validation:Enum=User;Group;ServiceAccount
26+
Kind string `json:"kind"`
27+
28+
// Name of the object being referenced.
29+
Name string `json:"name"`
30+
31+
// Namespace of the referenced object. Required if Kind is "ServiceAccount". Must not be specified if Kind is "User" or "Group".
32+
// +optional
33+
Namespace string `json:"namespace,omitempty"`
34+
}
35+
36+
// RbacV1 converts the Subject to a Kubernetes RBAC v1 Subject.
37+
func (s Subject) RbacV1() rbacv1.Subject {
38+
rs := rbacv1.Subject{
39+
Kind: s.Kind,
40+
Name: s.Name,
41+
Namespace: s.Namespace,
42+
}
43+
if s.Kind != rbacv1.ServiceAccountKind {
44+
rs.APIGroup = rbacv1.GroupName
45+
}
46+
return rs
47+
}

api/core/v2alpha1/zz_generated.deepcopy.go

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)