Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ vars:
ENVTEST_VERSION: release-0.19
CRD_DIRECTORY: config/crd/bases
KCP_APIGEN_VERSION: v0.29.0
KCP_VERSION: 0.28.3
KCP_VERSION: 0.29.0
GOLANGCI_LINT_VERSION: v2.8.0
GOARCH:
sh: go env GOARCH
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/identityproviderconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type IdentityProviderClientConfig struct {

// IdentityProviderConfigurationSpec defines the desired state of IdentityProviderConfiguration
type IdentityProviderConfigurationSpec struct {
Clients []IdentityProviderClientConfig `json:"clients"`
RegistrationAllowed bool `json:"registrationAllowed"`
Clients []IdentityProviderClientConfig `json:"clients"`
}

// ManagedClient tracks a client that is managed by the operator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ spec:
- redirectUris
type: object
type: array
registrationAllowed:
type: boolean
required:
- clients
- registrationAllowed
type: object
status:
description: status defines the observed state of IdentityProviderConfiguration
Expand Down
2 changes: 1 addition & 1 deletion config/resources/apiexport-core.platform-mesh.io.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
crd: {}
- group: core.platform-mesh.io
name: identityproviderconfigurations
schema: v260123-dbda1fc.identityproviderconfigurations.core.platform-mesh.io
schema: v260129-b6b2199.identityproviderconfigurations.core.platform-mesh.io
storage:
crd: {}
- group: core.platform-mesh.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
kind: APIResourceSchema
metadata:
creationTimestamp: null
name: v260123-dbda1fc.identityproviderconfigurations.core.platform-mesh.io
name: v260129-b6b2199.identityproviderconfigurations.core.platform-mesh.io
spec:
group: core.platform-mesh.io
names:
Expand Down Expand Up @@ -76,8 +76,11 @@ spec:
- redirectUris
type: object
type: array
registrationAllowed:
type: boolean
required:
- clients
- registrationAllowed
type: object
status:
description: status defines the observed state of IdentityProviderConfiguration
Expand Down
4 changes: 4 additions & 0 deletions internal/subroutine/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewIDPSubroutine(orgsClient client.Client, mgr mcmanager.Manager, cfg confi
additionalRedirectURLs: cfg.IDP.AdditionalRedirectURLs,
kubectlClientRedirectURLs: cfg.IDP.KubectlClientRedirectURLs,
baseDomain: cfg.BaseDomain,
registrationAllowed: cfg.IDP.RegistrationAllowed,
limiter: limiter,
}
}
Expand All @@ -55,6 +56,7 @@ type IDPSubroutine struct {
additionalRedirectURLs []string
kubectlClientRedirectURLs []string
baseDomain string
registrationAllowed bool
limiter workqueue.TypedRateLimiter[*v1alpha1.IdentityProviderConfiguration]
}

Expand Down Expand Up @@ -116,6 +118,8 @@ func (i *IDPSubroutine) Process(ctx context.Context, instance runtimeobject.Runt

idp := &v1alpha1.IdentityProviderConfiguration{ObjectMeta: metav1.ObjectMeta{Name: workspaceName}}
_, err = controllerutil.CreateOrPatch(ctx, cl.GetClient(), idp, func() error {
idp.Spec.RegistrationAllowed = i.registrationAllowed

for _, desired := range clients {
idp.Spec.Clients = ensureClient(idp.Spec.Clients, desired)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/subroutine/idp/subroutine.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *subroutine) Process(ctx context.Context, instance runtimeobject.Runtime
realmName := idpConfig.Name
oidcClient, adminClient := s.newOIDCClient(realmName)

if err := s.ensureRealm(ctx, adminClient, realmName, log); err != nil {
if err := s.ensureRealm(ctx, adminClient, realmName, idpConfig.Spec.RegistrationAllowed, log); err != nil {
return ctrl.Result{}, errors.NewOperatorError(err, true, false)
}

Expand Down Expand Up @@ -183,14 +183,14 @@ func (s *subroutine) Process(ctx context.Context, instance runtimeobject.Runtime
return ctrl.Result{}, nil
}

func (s *subroutine) ensureRealm(ctx context.Context, adminClient *keycloak.AdminClient, realmName string, log *logger.Logger) error {
func (s *subroutine) ensureRealm(ctx context.Context, adminClient *keycloak.AdminClient, realmName string, registrationAllowed bool, log *logger.Logger) error {
realmConfig := keycloak.RealmConfig{
Realm: realmName,
DisplayName: realmName,
Enabled: true,
LoginWithEmailAllowed: true,
RegistrationEmailAsUsername: true,
RegistrationAllowed: s.cfg.IDP.RegistrationAllowed,
RegistrationAllowed: registrationAllowed,
SSOSessionIdleTimeout: s.cfg.IDP.AccessTokenLifespan,
AccessTokenLifespan: s.cfg.IDP.AccessTokenLifespan,
}
Expand Down
Loading