From 7909825c791cf339415892da33e8b64fa6f76da7 Mon Sep 17 00:00:00 2001 From: Vojtech Szocs Date: Wed, 29 Oct 2025 19:30:04 +0000 Subject: [PATCH 1/3] Add copy to clipboard buttons to display token page --- pkg/server/tokenrequest/tokenrequest.go | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/pkg/server/tokenrequest/tokenrequest.go b/pkg/server/tokenrequest/tokenrequest.go index 7ed86387d..7954d8444 100644 --- a/pkg/server/tokenrequest/tokenrequest.go +++ b/pkg/server/tokenrequest/tokenrequest.go @@ -144,6 +144,8 @@ func (t *tokenRequest) displayTokenPost(osinOAuthClient *osincli.Client, w http. } data.AccessToken = accessData.AccessToken + data.AccessTokenJSStr = template.JSStr(data.AccessToken) + data.PublicMasterURLJSStr = template.JSStr(data.PublicMasterURL) renderToken(w, data) } @@ -178,9 +180,11 @@ type sharedData struct { type tokenData struct { sharedData - AccessToken string - PublicMasterURL string - LogoutURL string + AccessToken string + AccessTokenJSStr template.JSStr + PublicMasterURL string + PublicMasterURLJSStr template.JSStr + LogoutURL string } func getBaseURL(req *http.Request) (*url.URL, error) { @@ -214,6 +218,7 @@ const cssStyle = ` code,pre { font-family: Menlo, Monaco, Consolas, monospace; } code { font-weight: 300; font-size: 1.5em; margin-bottom: 1em; display: inline-block; color: #646464; } pre { padding-left: 1em; border-radius: 5px; color: #003d6e; background-color: #EAEDF0; padding: 1.5em 0 1.5em 4.5em; white-space: normal; text-indent: -2em; } + pre>button { margin-left: 1.5em; margin-right: 1.5em; float: right; } a { color: #00f; text-decoration: none; } a:hover { text-decoration: underline; } button { background: none; border: none; color: #00f; text-decoration: none; font: inherit; padding: 0; } @@ -232,11 +237,28 @@ var tokenTemplate = template.Must(template.New("tokenTemplate").Parse(

Your API token is

{{.AccessToken}} + +

Log in with this token

-
oc login --token={{.AccessToken}} --server={{.PublicMasterURL}}
+
+    oc login
+    --token={{.AccessToken}}
+    --server={{.PublicMasterURL}}
+    
+  

Use this token directly against the API

-
curl -H "Authorization: Bearer {{.AccessToken}}" "{{.PublicMasterURL}}/apis/user.openshift.io/v1/users/~"
+
+    curl
+    -H "Authorization: Bearer {{.AccessToken}}"
+    "{{.PublicMasterURL}}/apis/user.openshift.io/v1/users/~"
+    
+  
{{ end }}

From 34ca6e5170a4ae2fd9c53e85c5a54b51325fa9a8 Mon Sep 17 00:00:00 2001 From: Vojtech Szocs Date: Wed, 10 Dec 2025 20:26:21 +0100 Subject: [PATCH 2/3] Add Copy button feedback & add Show button to reveal data --- pkg/server/tokenrequest/tokenrequest.go | 86 +++++++++++++++++++------ 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/pkg/server/tokenrequest/tokenrequest.go b/pkg/server/tokenrequest/tokenrequest.go index 7954d8444..e03895f84 100644 --- a/pkg/server/tokenrequest/tokenrequest.go +++ b/pkg/server/tokenrequest/tokenrequest.go @@ -219,6 +219,8 @@ const cssStyle = ` code { font-weight: 300; font-size: 1.5em; margin-bottom: 1em; display: inline-block; color: #646464; } pre { padding-left: 1em; border-radius: 5px; color: #003d6e; background-color: #EAEDF0; padding: 1.5em 0 1.5em 4.5em; white-space: normal; text-indent: -2em; } pre>button { margin-left: 1.5em; margin-right: 1.5em; float: right; } + pre>button:disabled { color: #444; } + pre>button:disabled:hover { text-decoration: none; cursor: default; } a { color: #00f; text-decoration: none; } a:hover { text-decoration: underline; } button { background: none; border: none; color: #00f; text-decoration: none; font: inherit; padding: 0; } @@ -234,31 +236,77 @@ var tokenTemplate = template.Must(template.New("tokenTemplate").Parse( {{ if .Error }} {{ .Error }} {{ else }} -

Your API token is

- {{.AccessToken}} - +

Your API token is

+

+
   

Log in with this token

-
-    oc login
-    --token={{.AccessToken}}
-    --server={{.PublicMasterURL}}
-    
-  
+

 
   

Use this token directly against the API

-
-    curl
-    -H "Authorization: Bearer {{.AccessToken}}"
-    "{{.PublicMasterURL}}/apis/user.openshift.io/v1/users/~"
-    
-  
+

+
+  
 {{ end }}
 
 

From 89206d3bc472447ba9010d591300bc197601c66f Mon Sep 17 00:00:00 2001 From: Vojtech Szocs Date: Wed, 29 Apr 2026 16:37:47 +0000 Subject: [PATCH 3/3] Ensure that snippet content is treated as text only --- pkg/server/tokenrequest/tokenrequest.go | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/server/tokenrequest/tokenrequest.go b/pkg/server/tokenrequest/tokenrequest.go index e03895f84..5d03f335d 100644 --- a/pkg/server/tokenrequest/tokenrequest.go +++ b/pkg/server/tokenrequest/tokenrequest.go @@ -237,32 +237,36 @@ var tokenTemplate = template.Must(template.New("tokenTemplate").Parse( {{ .Error }} {{ else }}