Enabling mTLS security and delegated authentication using LDAP¶
Overview¶
In this guide, we will setup mTLS to secure the data in motion between the mq-spring-app and the QM1 queue manager. We will also setup an LDAP server to configure the system to delegate authentication of mq users (system and human) to an OpenLDAP server.
The details of the solution are described here mq security.
Prerequisites¶
You have a cluster provisioned with the mq-spring-app deployed and interacting with the QM1 queue manager without any security configured (i.e. no TLS and no LDAP for delegated authentication).
You have cloned the git repositories for: * multi-tenancy-gitops (https://github.com/cloud-native-toolkit/multi-tenancy-gitops) * mq-infra (https://github.com/cloud-native-toolkit/mq-infra) * mq-spring-app (https://github.com/cloud-native-toolkit/mq-spring-app)
Configure mTLS and Delegated Authentication¶
-
Create openldap project
Go to the
multi-tenancy-gitopsfolder where the local copy of the repo is:Edit filecd multi-tenancy-gitops0-bootstrap/single-cluster/1-infra/kustomization.yamland uncomment the line:Commit the change and push it back to the repo.- argocd/namespace-openldap.yamlThis will create thegit add . git commit -m "create openldap project" git push origin masteropenldapproject in the cluster. -
Install the OpenLDAP Server
Edit file
0-bootstrap/single-cluster/2-services/kustomization.yamland uncomment the line:- argocd/instances/openldap.yamlCommit the change and push it back to the repo.
This will create thegit add . git commit -m "enable OpenLDAP to be installed" git push origin masteropenldapArgo application and install OpenLDAP into the cluster in namespaceopenldap.In ArgoCD, when you search for the
openldapapplication, you should see a screen that look like this:
Once, ArgoCD Synchs with the OpenShift cluster, you will see two deployments in the
openldapproject as follows:
OpenLDAP has a admin UI to manage the users.
Get the route and open the admin UI in a browser:
oc get route openldap-admin -n openldap -o jsonpath='{ .spec.host }'The OpenLDAP admin UI will appear as follows:

Login using
Login DNcredentials:cn=admin,dc=ibm,dc=comand
password:adminOnce, you login, you will see several users in the directory including the
mqappuser which we will use in this guide.
-
Activate cert-manager Operator
Edit file
0-bootstrap/single-cluster/2-services/kustomization.yamland uncomment the line:- argocd/operators/cert-manager.yamlCommit the change and push it back to the repo
git add . git commit -m "enable cert-manager operator" git push origin masterThe cert-manager ArgoCD application will be created:

The cert-manager operator will show up in the OpenShift cluster.

-
Activate cert-manager instance
Edit file
0-bootstrap/single-cluster/2-services/kustomization.yamland uncomment the line:- argocd/instances/cert-manager-instance.yamlCommit the change and push it back to the repo
git add . git commit -m "enable cert-manager instance" git push origin masterThe cert-manager instance ArgoCD application will be created:

The cert-manager instance will show up in the OpenShift cluster.

-
Activate Certificate Issuer and Certificates
NOTE: ??? CHECK WITH HOLLIS. IS THIS GITOPS STRUCTURE STILL CORRECT????
Edit file
0-bootstrap/single-cluster/3-apps/kustomization.yamland uncomment the line:- argocd/mq/tools.yamlCommit the change and push it back to the repo
git add . git commit -m "enable certificate issuer" git push origin masterCreates the following resources in the cluster:
Resource type Resource name ClusterIssuer selfsigned-cluster-issuer Certificate mq-self-signed-ca-cert ClusterIssuer self-signed-mq-cluster-issuer 
-
Create JKS password secret
NOTE: master branch now has the script and the sealed secret yaml to generate the mq-client-jks-password secret. https://github.com/mqpdg2/multi-tenancy-gitops-apps/tree/master/mq/environments/ci/secrets So I believe this step does not need to be in this guide. I believe that the secret will exist at this point at least in the ci namespace. Not sure of the other namespaces.
-
Activate Certificates in ci namespace
Edit file `mq/environments/ci/kustomization.yaml and uncomment the line:
- certificates/ci-mq-client-certificate.yaml - certificates/ci-mq-server-certificate.yamlCommit the change and push it back to the repo
git add . git commit -m "create the mq client and server certificate in the ci namespace" git push origin masterVerify that the certificate was created successfully and the secret was generated by cert-manager.
oc get certificate -n ciYou should see the certificates with a
Readystatus ofTrueas follows:NAME READY SECRET AGE ci-mq-client-cert True mq-client-jks 5d16h ci-mq-server-cert True mq-server-cert 5d16hThe cert-manager operator generates the secrets from these certificates. Lets verify the secrets were generated correctly. Run the command:
oc get secret mq-client-jks -n ciYou should see the secret with a
Datavalue of5representing 5 key value pairs as follows:NAME TYPE DATA AGE mq-client-jks kubernetes.io/tls 5 5d16hRun the command:
You should see the secret with aoc get secret mq-server-cert -n ciDatavalue of3representing 3 key value pairs as follows:NAME TYPE DATA AGE mq-server-cert kubernetes.io/tls 3 5d17h -
Activate Certificates in dev namespace
Edit file `mq/environments/dev/kustomization.yaml and uncomment the line:
- certificates/dev-mq-client-certificate.yaml - certificates/dev-mq-server-certificate.yamlCommit the change and push it back to the repo
git add . git commit -m "create the mq client and server certificate in the dev namespace" git push origin masterVerify that the certificate was created successfully and the secret was generated by cert-manager.
oc get certificate -n devYou should see the certificates with a
Readystatus ofTrueas follows:NAME READY SECRET AGE dev-mq-client-cert True mq-client-jks 5d16h dev-mq-server-cert True mq-server-cert 5d16hThe cert-manager operator generates the secrets from these certificates. Lets verify the secrets were generated correctly. Run the command:
oc get secret mq-client-jks -n devYou should see the secret with a
Datavalue of5representing 5 key value pairs as follows:NAME TYPE DATA AGE mq-client-jks kubernetes.io/tls 5 5d16hRun the command:
You should see the secret with aoc get secret mq-server-cert -n ciDatavalue of3representing 3 key value pairs as follows:NAME TYPE DATA AGE mq-server-cert kubernetes.io/tls 3 5d17h -
Deploy/Create an mq manager instance with security enabled
Edit the values.yaml file in the source
mq-infrarepo and change the value of thesecurityto true as follows:security: trueCommit the change and push it back to the repo
git add . git commit -m "Build and deploy the mq manager with security enabled" git push origin masterRun the
mq-infra-devpipeline. From the OpenShift console, go to Pipelines and set the Project toci. You should see themq-infra-devpipeline as follows:
Click on the
mq-infra-devpipeline link. Click on theActionsdrop-down and selectStartas follows:
The
Start Pipelinescreen will pop up. Fill thegit-urlfield and use the defaults for the other fields. Then click theStartbutton.
Wait till the pipeline completes successfully.

The final stage of the pipeline will update the gitops repo:
multi-tenancy-gitops-apps/mq/environments/dev/mq-infra/which will force ArgoCD to deploy the secure MQ manager to thedevproject.Note: It may take a few minutes for ArgoCD to synch with the OpenShift cluster.
-
Deploy mq-spring-app with security enabled
Edit the values.yaml file in the source
mq-spring-apprepo and change the value of thesecurityto true as follows:security: trueCommit the change and push it back to the repo
git add . git commit -m "Build and deploy the mq-spring-app with security enabled" git push origin masterRun the
mq-spring-app-devpipeline. From the OpenShift console, go to Pipelines and set the Project toci. You should see themq-spring-app-devpipeline as follows:
Click on the
mq-spring-devpipeline link. Click on theActionsdrop-down and selectStartas follows:
The
Start Pipelinescreen will pop up. Fill thegit-urlfield and use the defaults for the other fields. Then click theStartbutton.
Wait till the pipeline completes successfully.

The final stage of the pipeline will update the gitops repo:
multi-tenancy-gitops-apps/mq/environments/dev/mq-spring-app/which will force ArgoCD to deploy the secure mq-spring-app client app to thedevproject.Note: It may take a few minutes for ArgoCD to synch with the OpenShift cluster.
-
Test the mq-spring-app
Check the health of the app:
export APP_URL=$(oc get route -n dev mq-spring-app -o jsonpath="{.spec.host}") curl -X GET https://$APP_URL/actuator/healthInvoke the api to put a message onto the queue:
curl -X GET https://$APP_URL/api/send-hello-worldInvoke the api to get a message from the queue:
curl -X GET https://$APP_URL/api/recvTo view the swagger docs of the
mq-spring-appapp, you can open a browser and enter the $APP_URL value.