- An OpenShift Cluster user with cluster-admin permissions
- The
oc
binary installed and user logged in - A Basic Authentication Service - you can find one to deploy to OpenShift in the
example-idp-service
directory
In this directory you can find a ./configure.sh
file that will allow you to quickly apply Basic Authentication to a logged in cluster. Edit the file and run as follows:
# Check configuration
./configure.sh
# Actually apply configuration
./configure.sh --commit
If you have a self-signed CA Certificate that needs to be provided to the OpenShift OAuth Configuration then you can create it with the following command, provided the PEM is located in the $HOME
directory:
oc create configmap myapp-basic-auth-ca-cert --from-file=ca.crt=$HOME/oidc-ca-cert.pem -n openshift-config
Replace the needed text in the following YAML with whatever your Client configuration is:
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: BASIC_AUTH_NAME_HERE
mappingMethod: claim
type: BasicAuth
basicAuth:
url: >-
HTTPS_ENDPOINT_HERE
ca:
name: myapp-basic-auth-ca-cert
Notes:
- Replace the BASIC_AUTH_NAME_HERE and HTTPS_ENDPOINT_HERE with your Basic Auth Service information
With the YAML created, we can apply it to the cluster now with the following command, assuming you saved it to a file called oauth.yaml:
WARNING The following command may overwrite your current IdP settings!
oc patch OAuth cluster --patch-file oauth.yaml
Once the Authentication Operator has restarted you should be able to log into the cluster with Basic Authentication!