Skip to content
Snippets Groups Projects
Commit cd65891b authored by Chrysoula Dikonimaki's avatar Chrysoula Dikonimaki
Browse files

check that ClientCredentialsSecret is set in appreg and validate secret

parent 411ac25e
No related branches found
No related tags found
1 merge request!21Update reconcile loop to check Secret instead of provisionStatus on ApplicationRegistration
Checking pipeline status
...@@ -3,7 +3,6 @@ package controllers ...@@ -3,7 +3,6 @@ package controllers
import ( import (
"context" "context"
"fmt" "fmt"
"reflect"
routev1 "github.com/openshift/api/route/v1" routev1 "github.com/openshift/api/route/v1"
authzalpha1 "gitlab.cern.ch/paas-tools/operators/authz-operator/api/v1alpha1" authzalpha1 "gitlab.cern.ch/paas-tools/operators/authz-operator/api/v1alpha1"
...@@ -39,7 +38,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag ...@@ -39,7 +38,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
// Ensure we have a valid ApplicationRegistration registration, this only happens when we have exactly one ApplicationRegistration // Ensure we have a valid ApplicationRegistration registration, this only happens when we have exactly one ApplicationRegistration
// with a status set by the authz-operator and this status says provisioning succeeded // with a status set by the authz-operator and this status says provisioning succeeded
if !reflect.DeepEqual(appReg.Status, authzalpha1.ApplicationRegistrationStatus{}) && appReg.Status.ClientCredentialsSecret != "oidc-client-secret" { if appReg.Status.ClientCredentialsSecret == "" {
meta.SetStatusCondition(&gitlabPagesSite.Status.Conditions, metav1.Condition{ meta.SetStatusCondition(&gitlabPagesSite.Status.Conditions, metav1.Condition{
Type: webservicescernchv1alpha1.ConditionTypeGitlabPagesSiteCreated, Type: webservicescernchv1alpha1.ConditionTypeGitlabPagesSiteCreated,
Status: metav1.ConditionFalse, Status: metav1.ConditionFalse,
...@@ -56,6 +55,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag ...@@ -56,6 +55,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
return nil, err return nil, err
} }
// Retrieve OIDC secret
oidcSecret := &v1.Secret{} oidcSecret := &v1.Secret{}
namespacedName := types.NamespacedName{ namespacedName := types.NamespacedName{
Name: appReg.Status.ClientCredentialsSecret, Name: appReg.Status.ClientCredentialsSecret,
...@@ -67,6 +67,14 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag ...@@ -67,6 +67,14 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
return nil, err return nil, err
} }
// Validate that the secret contains the required data
requiredFields := []string{"clientID", "clientSecret", "issuerURL"}
for _, field := range requiredFields {
if value, exists := oidcSecret.Data[field]; !exists || len(value) == 0 {
return nil, fmt.Errorf("secret '%s' in namespace '%s' is missing required field or has empty value: %s", appReg.Status.ClientCredentialsSecret, gitlabPagesSite.Namespace, field)
}
}
return oidcSecret, nil return oidcSecret, nil
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment