OpenUnison / openunison-k8s

Access portal for Kubernetes
Apache License 2.0
105 stars 5 forks source link

fix windows command in the token application #114

Open vrabbi opened 5 months ago

vrabbi commented 5 months ago

the windows command for configuring the kube context has an issue. it misconfigures the CA as it is using UTF8-BOM which adds weird characters at the front of the string.

this can be fixed by changing the following snippet from:

out-file \$TMP_CERT -encoding oem 

to:

set-content -path $TMP_CERT -encoding utf8

making the final config:

\$TMP_CERT=New-TemporaryFile ; "$k8s_newline_cert_win$" | set-content -path \$TMP_CERT -encoding utf8 ; kubectl config set-cluster #[K8S_CLUSTER_NAME:kubernetes] --server=#[K8S_URL]  --certificate-authority=\$TMP_CERT --embed-certs=true ; kubectl config set-context #[K8S_CLUSTER_NAME:kubernetes] --cluster=#[K8S_CLUSTER_NAME:kubernetes] --user=$user_id$@#[K8S_CLUSTER_NAME:kubernetes]  ; kubectl config set-credentials $user_id$@#[K8S_CLUSTER_NAME:kubernetes]  --auth-provider=oidc --auth-provider-arg=client-secret= --auth-provider-arg=idp-issuer-url=$token.claims.issuer$ --auth-provider-arg=client-id=$token.trustName$ --auth-provider-arg=refresh-token=$token.refreshToken$  --auth-provider-arg=id-token=$token.encodedIdJSON$  --auth-provider-arg=idp-certificate-authority-data=$ou_b64_cert$ ; kubectl config use-context #[K8S_CLUSTER_NAME:kubernetes] ; Remove-Item -recurse -force \$TMP_CERT