Skip to content

Instantly share code, notes, and snippets.

@surajnarwade
Created April 22, 2019 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surajnarwade/246997be066ba285fe327d51efa6f325 to your computer and use it in GitHub Desktop.
Save surajnarwade/246997be066ba285fe327d51efa6f325 to your computer and use it in GitHub Desktop.
#!/bin/bash
HTPASSWD_FILE="./htpass"
USERNAME="suraj1"
USERPASS="developer"
HTPASSWD_SECRET="htpasswd-secret1"
htpasswd -cb $HTPASSWD_FILE $USERNAME $USERPASS
oc get secret $HTPASSWD_SECRET -n openshift-config &> /dev/null
oc create secret generic ${HTPASSWD_SECRET} --from-file=htpasswd=${HTPASSWD_FILE} -n openshift-config
oc apply -f - <<EOF
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: htpassidp1
challenge: true
login: true
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: ${HTPASSWD_SECRET}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment