Skip to content

Commit

Permalink
fix: Reconcile Dex client secret when .spec.dex is set (argoproj-labs…
Browse files Browse the repository at this point in the history
…#877)

Signed-off-by: jannfis <jann@mistrust.net>
(cherry picked from commit a359b7c)
  • Loading branch information
jannfis authored and wtam2018 committed Mar 24, 2023
1 parent c62aa60 commit 9de9354
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controllers/argocd/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (r *ReconcileArgoCD) reconcileArgoSecret(cr *argoprojv1a1.ArgoCD) error {
common.ArgoCDKeyTLSPrivateKey: tlsSecret.Data[common.ArgoCDKeyTLSPrivateKey],
}

if cr.Spec.SSO != nil && cr.Spec.SSO.Provider == v1alpha1.SSOProviderTypeDex {
if cr.Spec.Dex != nil || (cr.Spec.SSO != nil && cr.Spec.SSO.Provider == v1alpha1.SSOProviderTypeDex) {
dexOIDCClientSecret, err := r.getDexOAuthClientSecret(cr)
if err != nil {
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 120
---
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
name: example-argocd
status:
phase: Available
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: example-argocd-argocd-dex-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
name: example-argocd
spec:
dex:
openShiftOAuth: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
# This test validates the Dex Client Secret copied by the operator from dex serviceaccount token secret in to argocd-secret.
# To verify the behavior we should first get the token secret name of the dex service account.
secret=$(oc get -n $NAMESPACE sa example-argocd-argocd-dex-server -o json | jq -r '.secrets' | grep token | sed 's/ "name": "//g' | sed 's/"//g')
# Extract the clientSecret
expectedClientSecret=$(oc get secret $secret -n $NAMESPACE -o json | jq -r '.data.token')
# actualClientSecret is the value of the secret in argocd-secret where argocd-operator should copy the secret from
actualClientSecret=$(oc get secret argocd-secret -o json -n $NAMESPACE | jq -r '.data."oidc.dex.clientSecret"')
# Verify
if $expectedClientSecret != $actualClientSecret; then
echo "Error: Dex Client Secret for OIDC is not valid"
exit 1
fi

0 comments on commit 9de9354

Please sign in to comment.