Skip to content

Commit

Permalink
Only include IDP certificate in kubectl if one is specified
Browse files Browse the repository at this point in the history
Add short description of result page title
Tweak CSS styles (for wrapping) and HTML templates (for language)
  • Loading branch information
whereisaaron committed Feb 14, 2018
1 parent 70c1214 commit 92d2b0d
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 39 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*~
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*~
2 changes: 2 additions & 0 deletions html/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ pre {
background-color: #eff0f1;
margin: 5px;
padding: 5px;
white-space: pre-wrap;
overflow-wrap: break-word;
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func start_app(config Config) {

var RootCmd = &cobra.Command{
Use: "dex-k8s-authenticator",
Short: "Dex Kubernetes Authentictor",
Short: "Dex Kubernetes Authenticator",
Long: `Dex Kubernetes Authenticator provides a web-interface to generate a kubeconfig file based on a selected Kubernetes cluster. One or more clusters can be defined in the configuration file.`,
Run: func(cmd *cobra.Command, args []string) {

Expand Down
54 changes: 28 additions & 26 deletions templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ func renderIndex(w http.ResponseWriter, config *Config) {
}

type tokenTmplData struct {
IDToken string
RefreshToken string
RedirectURL string
Claims string
Username string
Issuer string
ClusterName string
ClientSecret string
ClientID string
K8sMasterURI string
K8sCaURI string
IDPCaURI string
LogoURI string
IDToken string
RefreshToken string
RedirectURL string
Claims string
Username string
Issuer string
ClusterName string
ShortDescription string
ClientSecret string
ClientID string
K8sMasterURI string
K8sCaURI string
IDPCaURI string
LogoURI string
}

func (cluster *Cluster) renderToken(w http.ResponseWriter,
Expand All @@ -49,19 +50,20 @@ func (cluster *Cluster) renderToken(w http.ResponseWriter,
t, _ := template.ParseFiles("./templates/kubeconfig.html")

token_data := tokenTmplData{
IDToken: idToken,
RefreshToken: refreshToken,
RedirectURL: cluster.Redirect_URI,
Claims: string(claims),
Username: unix_username,
Issuer: data["iss"].(string),
ClusterName: cluster.Name,
ClientSecret: cluster.Client_Secret,
ClientID: cluster.Client_ID,
K8sMasterURI: cluster.K8s_Master_URI,
K8sCaURI: cluster.K8s_Ca_URI,
IDPCaURI: idpCaURI,
LogoURI: logoURI}
IDToken: idToken,
RefreshToken: refreshToken,
RedirectURL: cluster.Redirect_URI,
Claims: string(claims),
Username: unix_username,
Issuer: data["iss"].(string),
ClusterName: cluster.Name,
ShortDescription: cluster.Short_Description,
ClientSecret: cluster.Client_Secret,
ClientID: cluster.Client_ID,
K8sMasterURI: cluster.K8s_Master_URI,
K8sCaURI: cluster.K8s_Ca_URI,
IDPCaURI: idpCaURI,
LogoURI: logoURI}

t.Execute(w, token_data)

Expand Down
8 changes: 5 additions & 3 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<html>
<head>
<meta charset="utf-8">
<meta name="google" content="notranslate">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>Generate Kubernetes Token</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/static/main.css" rel="stylesheet">
<link href="/static/styles.css" rel="stylesheet">
<link href="/static/main.css" rel="stylesheet" type="text/css">
<link href="/static/styles.css" rel="stylesheet" type="text/css">
<link rel="icon" href="/static/favicon.png">
</head>

Expand Down Expand Up @@ -46,4 +49,3 @@ <h2 class="theme-heading">Generate Kubernetes Token</h2>
</div>
</body>
</html>

25 changes: 16 additions & 9 deletions templates/kubeconfig.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="google" content="notranslate">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>Kubernetes Configuration</title>
<link href="/static/main.css" rel="stylesheet" type="text/css" />
<link href="/static/styles.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="/static/favicon.png" />
</head>
<title>Kubernetes Configuration</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/static/main.css" rel="stylesheet" type="text/css">
<link href="/static/styles.css" rel="stylesheet" type="text/css">
<link rel="icon" href="/static/favicon.png">
</head>

<body class="theme-body">
<div class="theme-navbar">
Expand All @@ -22,7 +27,7 @@
<div style="float:right">
<a href="/">Login Again</a>
</div>
<h2 class="theme-heading">Generated Kubernetes Token - {{ .ClusterName }}</h2>
<h2 class="theme-heading">Generated Kubernetes Token - {{ .ShortDescription }}</h2>

<div>
<p>Your token for this cluster has been generated, please follow the steps
Expand Down Expand Up @@ -61,7 +66,9 @@ <h3>Run configuration commands</h3>
--auth-provider-arg=client-id={{ .ClientID }} \
--auth-provider-arg=client-secret={{ .ClientSecret }} \
--auth-provider-arg=refresh-token={{ .RefreshToken }} \
{{- if .IDPCaURI }}
--auth-provider-arg=idp-certificate-authority=${HOME}/.kube/certs/{{ .ClusterName }}/idp-ca.crt \
{{- end }}
--auth-provider-arg=id-token={{ .IDToken }}</code></pre>

<pre><code>kubectl config set-context {{ .Username }}-{{ .ClientID }} \
Expand Down

0 comments on commit 92d2b0d

Please sign in to comment.