export SSO_IP=`kubectl get svc -A | grep "sso " | awk '{print $4}'`
export ASMUI_PASS=`kubectl get secret pfxm-asmui-creds -o json -n powerflex | jq '.data | map_values(@base64d)' | jq -r '.["keycloak-password"]'`
export PM_TOKEN=`curl -k --location --request POST "https://${SSO_IP}:8080/rest/auth/login" --header 'Accept: application/json' --header 'Content-Type: application/json' --data "{\"username\": \"asmuiuser\",\"password\": \"$ASMUI_PASS\"}" | jq -r .access_token`
export IN_IP=`kubectl get svc -A | grep -m1 rke2-ingress-nginx-controller | sort | awk '{print $5}'`

curl -kL -X POST --url https://$IN_IP/rest/v1/oidc-sp-config  --header 'Content-Type: application/json' --header "Authorization: Bearer ${PM_TOKEN}" --data "{
  \"sp_id\": \"powerflex-$IN_IP\",
  \"redirect_uri\": \"https://$IN_IP/auth/realms/powerflex/protocol/openid-connect/auth\",
  \"logout_uri\": \"https://$IN_IP/auth/realms/powerflex/protocol/openid-connect/logout\",
  \"required_claims\": [\"email\"],
  \"keycloak_settings\": {
    \"config\": {
      \"clientAuthMethod\": \"client_secret_basic\",
      \"pkceEnabled\": \"true\",
      \"useJwksUrl\": \"true\",
      \"validateSignature\": \"true\"
    },
    \"first_broker_login_flow_alias\": \"first broker login\",
    \"post_broker_login_flow_alias\": null,
    \"link_only\": null,
    \"store_token\": true,
    \"add_read_token_role_on_create\": true,
    \"trust_email\": true
  },
  \"days_to_store_state_code_verifier\": 1}"

