Configure an LDAP identity provider and automate group synchronization between OpenShift OAuth and an LDAP server.
Outcomes
Configure an LDAP identity provider (IdP) for RHOCP.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
[student@workstation ~]$ lab start auth-ldap
Instructions
Your company requires you to configure a Red Hat Directory Services (RHDS) Identity Provider (IdP), which is available on the rhds machine as an LDAP IdP for RHOCP.
LDAP administration is outside the scope of this course. The RHDS server is already correctly configured for this exercise.
As the admin user, locate and then navigate to the Red Hat OpenShift web console.
Use the terminal to log in to the OpenShift cluster as the admin user with the redhatocp password.
[student@workstation ~]$ oc login -u admin -p redhatocp \
https://api.ocp4.example.com:6443
...output omitted...Identify the URL for the OpenShift web console.
[student@workstation ~]$ oc whoami --show-console
https://console-openshift-console.apps.ocp4.example.comOpen a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com.
Either type the URL in a web browser, or right-click and select Open Link from the terminal.
![]() |
Log in to the OpenShift web console as the admin user.
Click and log in as the admin user with the redhatocp password.
![]() |
Navigate to the Configuration page for OAuth in the RHOCP cluster web console.
Click > from the sidebar.
![]() |
Click the tab to browse the list of configurable resources.
![]() |
Scroll through the alphabetical list of configuration resources and select OAuth.
![]() |
View the existing YAML configuration for the Red Hat Identity Management IdP.
Click the tab and scroll down to the bottom of the configuration file.
![]() |
You can view the cluster OAuth configuration from the CLI in YAML format, by using the oc get oauth cluster --output yaml command.
You can also view the cluster OAuth configuration details from the CLI, by using the oc describe oauth command.
The settings for the existing Red Hat Identity Management IdP are shown in the spec keys on lines 57-78.
spec:
identityProviders:
- ldap:
attributes:
email:
- mail
id:
- dn
name:
- cn
preferredUsername:
- uid
bindDN: 'uid=admin,cn=users,cn=accounts,dc=ocp4,dc=example,dc=com'
bindPassword:
name: ldap-secret
ca:
name: ca-config-map
insecure: false
url: >-
ldap://idm.ocp4.example.com/cn=users,cn=accounts,dc=ocp4,dc=example,dc=com?uid
mappingMethod: claim
name: Red Hat Identity Management
type: LDAPFrom the CLI, test the RHDS credentials to ensure a valid LDAP connection, before configuring the additional IdP.
Open a terminal on the workstation, and create an ldapsearch query with the information in the following table:
| Query option | Value |
|---|---|
Base DN (-D) | cn=Directory Manager |
URI (-H) |
ldaps://rhds.ocp4.example.com
|
| Password (-w) |
redhatocp
|
From the CLI, test the ldapsearch connection by using the authored query.
With the -w option that is shown, you can supply the password, in plain text.
[student@workstation ~] ldapsearch -D "cn=Directory Manager" \
-w redhatocp -H ldaps://rhds.ocp4.example.com
# extended LDIF
#
# LDAPv3
# base <> (default) with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# example.com
dn: dc=example,dc=com
objectClass: top
objectClass: domain
dc: example
description: dc=example,dc=com
# people, example.com
dn: ou=people,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: people
# kristendelgado, people, example.com
dn: uid=kristendelgado,ou=people,dc=example,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
objectClass: nsMemberOf
cn: Kristen Delgado
uid: kristendelgado
uidNumber: 10001
gidNumber: 101
homeDirectory: /home/kristendelgado
loginShell: /bin/bash
gecos: kristendelgado
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
userPassword:: e1NTSEF9Wm1sMWd1WjJLajlRM1dKZGlFVnV6aTNEaCs5NzFPeFg=
memberOf: cn=administrators,ou=people,dc=example,dc=com
# administrators, people, example.com
dn: cn=administrators,ou=people,dc=example,dc=com
objectClass: top
objectClass: groupOfUniqueNames
cn: administrators
uniqueMember: uid=kristendelgado,ou=people,dc=example,dc=com
# search result
search: 2
result: 0 Success
# numResponses: 5
# numEntries: 4In the web console, add a new IdP for RHDS by using the validated information.
Return to the previous page by clicking the tab.
The existing Red Hat Identity Management IdP is shown in the list of available IdPs.
In the Identity providers section, select LDAP from the dropdown.
![]() |
Complete the corresponding form fields by using the information in the following table:
| Form field | Value |
|---|---|
| Name | Red Hat Directory Server |
| URL & BaseDN |
ldaps://rhds.ocp4.example.com/dc=example,dc=com?uid
|
| Bind DN |
cn=Directory Manager
|
| Bind password |
redhatocp
|
mail
|
Use the default values for all other fields.
In the CA File field, enter the certificate for the RHDS server from the rhds classroom machine, which is provided on the workstation machine in the file /home/student/DO380/labs/auth-ldap/rhds_ca.crt.
[student@workstation ~] cat /home/student/DO380/labs/auth-ldap/rhds_ca.crt
-----BEGIN CERTIFICATE-----
...output omitted...Click .
![]() |
Verify the addition of the new IdP.
View the new entry in the IdP list on the OAuth details page.
![]() |
Review the configuration additions on the tab on lines 78-98.
spec:
identityProviders:
- ldap:
attributes:
email:
- mail
id:
- dn
name:
- cn
preferredUsername:
- uid
bindDN: 'cn=Directory Manager'
bindPassword:
name: ldap-bind-password-cjckt
ca:
name: ca-config-map
insecure: false
url: >-
ldaps://rhds.ocp4.example.com/dc=example,dc=com?uid
mappingMethod: claim
name: Red Hat Directory Server
type: LDAPFrom the upper-right dropdown menu, log out of the web console to return to the authentication page.
![]() |
The new IdP appears in the list as Red Hat Directory Server.
![]() |
It might take several minutes for the cluster to redeploy the pods and for the new IdP to appear.
Select the Red Hat Directory Server IdP, and verify the authentication function by using the kristendelgado username and the redhat123 password to log in to the cluster.