$ htpasswd -c -B -b </path/to/users.htpasswd> <user_name> <password>
By default, only a kubeadmin
user exists on your cluster. To specify an
identity provider, you must create a Custom Resource (CR) that describes
that identity provider and add it to the cluster.
OpenShift Container Platform user names containing |
To define an HTPasswd identity provider you must perform the following steps:
Create an htpasswd
file to store the user and password information.
Instructions are provided for
Linux
and
Windows.
Create
an OpenShift Container Platform secret to represent the htpasswd
file.
To use the HTPasswd identity provider, you must generate a flat file that
contains the user names and passwords for your cluster by using
htpasswd
.
Have access to the htpasswd
utility. On Red Hat Enterprise Linux
this is available by installing the httpd-tools
package.
Create or update your flat file with a user name and hashed password:
$ htpasswd -c -B -b </path/to/users.htpasswd> <user_name> <password>
The command generates a hashed version of the password.
For example:
$ htpasswd -c -B -b users.htpasswd user1 MyPassword! Adding password for user user1
Continue to add or update credentials to the file:
$ htpasswd -b </path/to/users.htpasswd> <user_name> <password>
To use the HTPasswd identity provider, you must generate a flat file that
contains the user names and passwords for your cluster by using
htpasswd
.
Have access to htpasswd.exe
. This file is included in the \bin
directory of many Apache httpd distributions.
Create or update your flat file with a user name and hashed password:
> htpasswd.exe -c -B -b <\path\to\users.htpasswd> <user_name> <password>
The command generates a hashed version of the password.
For example:
> htpasswd.exe -c -B -b users.htpasswd user1 MyPassword! Adding password for user user1
Continue to add or update credentials to the file:
> htpasswd.exe -b <\path\to\users.htpasswd> <user_name> <password>
To use the HTPasswd identity provider, you must define a secret that contains the HTPasswd user file.
Create an HTPasswd file.
Create an OpenShift Container Platform secret that contains the HTPasswd users file.
$ oc create secret generic htpass-secret --from-file=htpasswd=</path/to/users.htpasswd> -n openshift-config
The secret key containing the users file for the |
The following Custom Resource (CR) shows the parameters and acceptable values for an HTPasswd identity provider.
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: my_htpasswd_provider (1)
mappingMethod: claim (2)
type: HTPasswd
htpasswd:
fileData:
name: htpass-secret (3)
1 | This provider name is prefixed to provider user names to form an identity name. |
2 | Controls how mappings are established between this provider’s identities and user objects. |
3 | An existing secret containing a file generated using
htpasswd . |
After you install your cluster, add an identity provider to it so your users can authenticate.
Create an OpenShift Container Platform cluster.
Create the Custom Resource (CR) for your identity providers.
You must be logged in as an administrator.
Apply the defined CR:
$ oc apply -f </path/to/CR>
If a CR does not exist, |
Log in to the cluster as a user from your identity provider, entering the password when prompted.
$ oc login -u <username>
Confirm that the user logged in successfully, and display the user name.
$ oc whoami
Configure your identity provider (IDP) through the web console instead of the CLI.
You must be logged in to the web console as a cluster administrator.
Navigate to Administration → Cluster Settings.
Under the Global Configuration tab, click OAuth.
Under the Identity Providers section, select your identity provider from the Add drop-down menu.
You can specify multiple IDPs through the web console without overwriting existing IDPs. |