Skip to content

Commit

Permalink
Merge pull request mintel#67 from mintel/feat-idp-ca-inline
Browse files Browse the repository at this point in the history
Added IDPCaPem option to support idp-ca via pem file
  • Loading branch information
nabadger authored Aug 30, 2018
2 parents 45a609b + ddc421d commit 4d00f80
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 6 deletions.
3 changes: 3 additions & 0 deletions charts/dex-k8s-authenticator/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ data:
{{- if .idpCaURI }}
idp_ca_uri: {{ .idpCaURI }}
{{- end }}
{{- if .idpCaPem }}
idp_ca_pem: {{ .idpCaPem }}
{{- end }}
{{- if and .tlsCert .tlsKey }}
tls_cert: "{{ .tlsCert }}"
tls_key: "{{ .tlsKey }}"
Expand Down
1 change: 1 addition & 0 deletions dex-auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (cluster *Cluster) handleCallback(w http.ResponseWriter, r *http.Request) {

cluster.renderToken(w, rawIDToken, token.RefreshToken,
cluster.Config.IDP_Ca_URI,
cluster.Config.IDP_Ca_Pem,
cluster.Config.Logo_Uri,
cluster.Config.Web_Path_Prefix,
viper.GetString("kubectl_version"),
Expand Down
9 changes: 5 additions & 4 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ An example configuration is available [here](../examples/config.yaml)
| Name | Required | Context | Description |
|-------------------|----------|---------|---------------------------------------------------------------------------------------|
| name | yes | cluster | Internal id of cluster |
| short_description | yes | cluster | Short description of cluster |
| description | yes | cluster | Extended description of cluster |
| short_description | yes | cluster | Short description of cluster |
| description | yes | cluster | Extended description of cluster |
| client_secret | yes | cluster | OAuth2 client-secret (shared between dex-k8s-auth and dex) |
| client_id | yes | cluster | OAuth2 client-id public identifier (shared between dex-k8s-auth and dex) |
| issuer | yes | cluster | Dex issuer url |
Expand All @@ -20,8 +20,9 @@ An example configuration is available [here](../examples/config.yaml)
| tls_cert | no | root | Path to TLS cert if SSL enabled |
| tls_key | no | root | Path to TLS key if SSL enabled |
| idp_ca_uri | no | root | A url pointing to the CA for generating 'idp-certificate-authority' in the kubeconfig |
| idp_ca_pem | no | root | The CA for generating 'idp-certificate-authority' in the kubeconfig |
| trusted_root_ca | no | root | A list of trusted-root CA's to be loaded by dex-k8s-auth at runtime |
| listen | yes | root | The listen address/port |
| listen | yes | root | The listen address/port |
| web_path_prefix | no | root | A path-prefix to serve dex-k8s-auth at (defaults to '/') |
| kubectl_version | no | root | A kubectl-version string that is used to provided a download path |
| logo_uri | no | root | A url pointing to a logo image that is displayed in the header |
Expand Down Expand Up @@ -69,4 +70,4 @@ Don't forget to update the Dex `staticClients.redirectURIs` value to include the

The `dex-k8s-authenticator` helm charts support this via the `dexK8sAuthenticator.web_path_prefix` and `ingress.path` options. You typically set these to the same value.

Note that the health-checks are configured automatically.
Note that the health-checks are configured automatically.
15 changes: 15 additions & 0 deletions examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ clusters:
# tls_cert: /path/to/dex-client.crt
# tls_key: /path/to/dex-client.key

# CA for your IDP - used in WebUI instructions for generating
# kubeconfig
# Both idp_ca_uri and idp_ca_pem are optional - you typically specifiy
# one or the other if required
#
# Provides a link to the CA from a hosted site
# idp_ca_uri: http://url-to-your-ca.crt
#
# Provides abililty to specify CA inline
# idp_ca_pem: |
# -----BEGIN CERTIFICATE-----
# ...
# -----END CERTIFICATE-----


# Which address to listen on (set to https if tls configured)
listen: http://127.0.0.1:5555

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type Config struct {
TLS_Cert string
TLS_Key string
IDP_Ca_URI string
IDP_Ca_Pem string
Logo_Uri string
Trusted_Root_Ca []string
}
Expand Down
3 changes: 3 additions & 0 deletions templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type templateData struct {
K8sCaURI string
K8sCaPem string
IDPCaURI string
IDPCaPem string
LogoURI string
Web_Path_Prefix string
KubectlVersion string
Expand All @@ -46,6 +47,7 @@ func (cluster *Cluster) renderToken(w http.ResponseWriter,
idToken,
refreshToken string,
idpCaURI string,
idpCaPem string,
logoURI string,
webPathPrefix string,
kubectlVersion string,
Expand Down Expand Up @@ -75,6 +77,7 @@ func (cluster *Cluster) renderToken(w http.ResponseWriter,
K8sCaURI: cluster.K8s_Ca_URI,
K8sCaPem: cluster.K8s_Ca_Pem,
IDPCaURI: idpCaURI,
IDPCaPem: idpCaPem,
LogoURI: logoURI,
Web_Path_Prefix: webPathPrefix,
KubectlVersion: kubectlVersion}
Expand Down
19 changes: 18 additions & 1 deletion templates/linux-mac-common.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ define "linux-mac-common" }}
{{ if .IDPCaURI }}
<h3>Copy IDP CA Certificate</h3>
<h3>Copy IDP CA Certificate From URL</h3>

<p>Copy this CA Certificate and download it to your .kube directory</p>
<div class="command">
Expand All @@ -12,6 +12,23 @@ <h3>Copy IDP CA Certificate</h3>
</div>
{{ end }}

{{ if .IDPCaPem }}
<h3>Copy IDP CA Certificate From PEM</h3>

<p>Put the CA Certificate into your .kube directory</p>

<div class="command">

<button class="btn" style="float:right" data-clipboard-snippet="">
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>
<pre><code>mkdir -p ${HOME}/.kube/certs/{{ .ClusterName }}/ &amp;&amp; cat &lt;&lt; EOF &gt; ${HOME}/.kube/certs/{{ .ClusterName }}/idp-ca.crt
{{ .IDPCaPem }}
EOF</code></pre>
</div>
{{ end }}


{{ if .K8sCaURI }}
<h3>Copy Kubernetes CA Certificate From URL</h3>

Expand Down
19 changes: 18 additions & 1 deletion templates/windows-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3>Install and Set Up kubectl</h3>
</div>

{{ if .IDPCaURI }}
<h3>Copy IDP CA Certificate</h3>
<h3>Copy IDP CA Certificate From URL</h3>

<p>Copy this CA Certificate and download it to your .kube directory</p>
<div class="command">
Expand All @@ -30,6 +30,23 @@ <h3>Copy IDP CA Certificate</h3>
</div>
{{ end }}

{{ if .IDPCaPem }}
<h3>Copy IDP CA From Pem</h3>

<p>Put the CA Certificate into your .kube directory</p>
<div class="command">

<button class="btn" style="float:right" data-clipboard-snippet="">
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>

<pre><code>mkdir -p ${HOME}/.kube/certs/{{ .ClusterName }}/ &amp;&amp; cat &lt;&lt; EOF &gt; ${HOME}/.kube/certs/{{ .ClusterName }}/idp-ca.crt
{{ .IDPCaPem}}
EOF</code></pre>
</div>
{{ end }}


{{ if .K8sCaURI }}
<h3>Copy Kubernetes CA Certificate From URL</h3>

Expand Down

0 comments on commit 4d00f80

Please sign in to comment.