Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read dex clientSecret from argocd-secret #847

Merged
merged 3 commits into from
Feb 3, 2023
Merged

feat: read dex clientSecret from argocd-secret #847

merged 3 commits into from
Feb 3, 2023

Conversation

iam-veeramalla
Copy link
Collaborator

Signed-off-by: iam-veeramalla abhishek.veeramalla@gmail.com

What type of PR is this?

/kind enhancement

What does this PR do / why we need it:
This PR will introduce a behavioral change in the way operator configures Dex for OpenShift connector.

Currently, Operator configures dex openshift connector to the Argo CD Instance when .spec.dex.OpenShiftOAuth: true && .spec.provider: dex. While this configuration works as expected, the oidc configuration which includes the clientSecret is placed in the configmap as plain text. This can be a security risk.

Once this PR is merged, operator will provide the reference of the clientSecret in the configmap and not the actual secret. Argo CD Server will read this clientSecret reference from argocd-secret.

The new configuration will look something like below
kubectl get cm argocd-cm -oyaml

data:
  .....
  dex.config: |
    connectors:
    - config:
        ....
        clientSecret: $oidc.dex.clientSecret
       .....
       .....

Have you updated the necessary documentation?
NA

How to test changes / Special notes to the reviewer:

  1. Run the operator locally using make install run
  2. Use the below Argo CD CR to create Argo CD Instance with Dex configuration.
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
  name: example-argocd
  labels:
    example: route
spec:
  sso:
   provider: dex
   dex:
    openShiftOAuth: true
  server:
    route:
      enabled: true
  1. Login into the Argo CD UI using the route url.
  2. Verify that the login is working fine with the new implementation.
  3. Verify in the Argo CD Configmap that clientSecret is not comprised but is just a reference to the oidc.dex.clientSecret in argocd-secret.

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
Copy link
Collaborator

@jannfis jannfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with a minor comment.

@@ -164,7 +160,7 @@ func (r *ReconcileArgoCD) getOpenShiftDexConfig(cr *argoprojv1a1.ArgoCD) (string
Config: map[string]interface{}{
"issuer": "https://kubernetes.default.svc", // TODO: Should this be hard-coded?
"clientID": getDexOAuthClientID(cr),
"clientSecret": *clientSecret,
"clientSecret": "$oidc.dex.clientSecret",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have defined the ArgoCDDexSecretKey constant already, would it make sense to use it here?

Copy link
Collaborator

@reginapizza reginapizza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works for me! The original request was that the user wished that the token would not be exposed as that is a security concern, but an additional issue we were running into was that even writing the clientSecret in a variable was getting overwritten during reconciliation. With this PR even if the user wishes to change their secret, they can do so in argocd-secret and it won't get overwritten. Two birds with one stone- thanks Abhishek! :D

@@ -228,4 +228,7 @@ const (

// ArgoCDServerClusterRoleEnvName is an environment variable to specify a custom cluster role for Argo CD server
ArgoCDServerClusterRoleEnvName = "SERVER_CLUSTER_ROLE"

// ArgoCDDexSecretKey is used to reference Dex secret from Argo CD secret into Argo CD configmap
ArgoCDDexSecretKey = "oidc.dex.clientSecret"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be $oidc.dex.clientSecret?

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
@iam-veeramalla iam-veeramalla merged commit 359585e into argoproj-labs:master Feb 3, 2023
iam-veeramalla added a commit that referenced this pull request Feb 3, 2023
* feat: read dex clientSecret from argocd-secret



* chore: add example file for dex openshift connector



* fix: upgrade path and unit tests



---------

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
ciiay pushed a commit to ciiay/argocd-operator that referenced this pull request Mar 21, 2023
* feat: read dex clientSecret from argocd-secret

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>

* chore: add example file for dex openshift connector

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>

* fix: upgrade path and unit tests

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>

---------

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
Signed-off-by: Yi Cai <yicai@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants