Skip to content

Instantly share code, notes, and snippets.

@jewzaam
Created June 25, 2019 21:21
Show Gist options
  • Save jewzaam/886d638e5bc4c78d21008590527ca8d3 to your computer and use it in GitHub Desktop.
Save jewzaam/886d638e5bc4c78d21008590527ca8d3 to your computer and use it in GitHub Desktop.
SyncIdentityProvider & SyncSet (secret) for htpasswd
PASSWORD=
CLUSTER_NAME=
CLUSTER_NAMESPACE=
touch htpasswd
htpasswd -b htpasswd customer-admin $PASSWORD
htpasswd -b htpasswd customer-user $PASSWORD
oc create secret generic htpasswd-secret --from-file=htpasswd=htpasswd -n openshift-config --dry-run -o yaml > htpasswd-secret.yaml
sed -i '0,/^/{s/^/ - /}' htpasswd-secret.yaml
sed -i 's/^\(..[^-]\)/ \1/g' htpasswd-secret.yaml
cat << EOF > htpasswd-secret.syncset.yaml
apiVersion: hive.openshift.io/v1alpha1
kind: SelectorSyncSet
metadata:
name: htpasswd-secret
namespace: $CLUSTER_NAMESPACE
spec:
clusterDeploymentRefs:
- name: $CLUSTER_NAME
resourceApplyMode: sync
resources:
EOF
cat htpasswd-secret.yaml >> htpasswd-secret.syncset.yaml
cat << EOF > htpasswd.syncidentityprovider.yaml
apiVersion: hive.openshift.io/v1alpha1
kind: SyncIdentityProvider
metadata:
name: $CLUSTER_NAME
namespace: $CLUSTER_NAMESPACE
spec:
clusterDeploymentRefs:
- name: $CLUSTER_NAME
identityProviders:
- challenge: true
login: true
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpasswd-secret
name: htpasswd
EOF
oc create -f htpasswd-secret.syncset.yaml
oc create -f htpasswd.syncidentityprovider.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment