Home

oidc @main - refs - log -
-
https://git.jolheiser.com/oidc.git
Simple OIDC callback viewer
tree log patch
web app Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQFUakzKNnH2lX40u8U547UCey0VL7hVjykqYzDu5ksPz8/KHS0kHXrPt/Apy6xUvSG u+btbYSsx+TyriyeE8YAg= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
3 weeks ago
6 changed files, 617 additions(+), 93 deletions(-)
main.gostatic/index.gotmplstatic/prism.cssstatic/prism.jsstatic/script.jsstatic/styles.css
M main.gomain.go
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
diff --git a/main.go b/main.go
index 2932e4f5d32cfd9a01cb1fb109dd5124556b0937..0f4240dc0d1ab48969c9aab39a907c608344d64d 100644
--- a/main.go
+++ b/main.go
@@ -3,11 +3,14 @@
 import (
 	"context"
 	"crypto/rand"
+	"embed"
 	"encoding/base64"
 	"encoding/json"
 	"flag"
 	"fmt"
+	"html/template"
 	"io"
+	"io/fs"
 	"log"
 	"net/http"
 	"os"
@@ -19,6 +22,15 @@ 	"github.com/peterbourgon/ff/v3"
 	"golang.org/x/oauth2"
 )
 
+var (
+	//go:embed static/*
+	_staticFiles   embed.FS
+	staticFiles, _ = fs.Sub(_staticFiles, "static")
+	//go:embed static/index.gotmpl
+	indexFile string
+	indexTmpl = template.Must(template.New("").Parse(indexFile))
+)
+
 func randString(nByte int) (string, error) {
 	b := make([]byte, nByte)
 	if _, err := io.ReadFull(rand.Reader, b); err != nil {
@@ -44,127 +56,265 @@ 	clientID       string
 	clientSecret   string
 	port           int
 	scopes         string
+	origin         string
 }
 
-func main() {
-	var args args
-	fs := flag.NewFlagSet("oidc", flag.ExitOnError)
-	fs.StringVar(&args.clientProvider, "client-provider", "", "Client provider (e.g. https://accounts.google.com)")
-	fs.StringVar(&args.clientID, "client-id", "", "Client ID")
-	fs.StringVar(&args.clientSecret, "client-secret", "", "Client secret")
-	fs.IntVar(&args.port, "port", 8000, "Port to run on")
-	fs.StringVar(&args.scopes, "scopes", "profile,email", "Comma-delimited scopes")
-	fs.String("config", ".env", "Env config")
-	if err := ff.Parse(fs, os.Args[1:],
-		ff.WithEnvVarPrefix("OIDC"),
-		ff.WithConfigFileFlag("config"),
-		ff.WithAllowMissingConfigFile(true),
-		ff.WithConfigFileParser(ff.EnvParser),
-	); err != nil {
-		log.Fatal(err)
+func (a args) redirect() string {
+	return strings.TrimSuffix(a.origin, "/") + "/callback"
+}
+
+type OIDCConfig struct {
+	ClientProvider string `json:"client_provider"`
+	ClientID       string `json:"client_id"`
+	ClientSecret   string `json:"client_secret"`
+	Scopes         string `json:"scopes"`
+}
+
+type Server struct {
+	args args
+
+	issuer       string
+	scopes       string
+	provider     *oidc.Provider
+	verifier     *oidc.IDTokenVerifier
+	oauth2Config *oauth2.Config
+}
+
+type IndexContext struct {
+	Issuer       string
+	ClientID     string
+	ClientSecret string
+	Scopes       string
+	RedirectURI  string
+
+	Results       bool
+	TokenClaims   string
+	UserInfo      string
+	TokenResponse string
+}
+
+func (s *Server) updateConfig(ctx context.Context, config *OIDCConfig) error {
+	if config.ClientProvider == "" || config.ClientID == "" {
+		return fmt.Errorf("client provider and client ID are required")
 	}
-	ctx := context.Background()
-	scopes := strings.Split(args.scopes, ",")
 
-	provider, err := oidc.NewProvider(ctx, args.clientProvider)
+	provider, err := oidc.NewProvider(ctx, config.ClientProvider)
 	if err != nil {
-		log.Fatal(err)
+		return fmt.Errorf("failed to create OIDC provider: %v", err)
 	}
+
 	oidcConfig := &oidc.Config{
-		ClientID: args.clientID,
+		ClientID: config.ClientID,
 	}
 	verifier := provider.Verifier(oidcConfig)
 
-	config := oauth2.Config{
-		ClientID:     args.clientID,
-		ClientSecret: args.clientSecret,
+	scopes := strings.Fields(config.Scopes)
+	if len(scopes) == 0 {
+		scopes = []string{"profile", "email"}
+	}
+
+	oauth2Config := &oauth2.Config{
+		ClientID:     config.ClientID,
+		ClientSecret: config.ClientSecret,
 		Endpoint:     provider.Endpoint(),
-		RedirectURL:  fmt.Sprintf("http://localhost:%d/callback", args.port),
+		RedirectURL:  s.args.redirect(),
 		Scopes:       append([]string{oidc.ScopeOpenID}, scopes...),
 	}
 
-	mux := http.NewServeMux()
-	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
-		state, err := randString(16)
-		if err != nil {
-			http.Error(w, "Internal error", http.StatusInternalServerError)
-			return
-		}
-		nonce, err := randString(16)
-		if err != nil {
-			http.Error(w, "Internal error", http.StatusInternalServerError)
-			return
-		}
-		setCallbackCookie(w, r, "state", state)
-		setCallbackCookie(w, r, "nonce", nonce)
+	s.issuer = config.ClientProvider
+	s.scopes = config.Scopes
+	s.provider = provider
+	s.verifier = verifier
+	s.oauth2Config = oauth2Config
 
-		http.Redirect(w, r, config.AuthCodeURL(state, oidc.Nonce(nonce)), http.StatusFound)
-	})
+	return nil
+}
 
-	mux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
-		state, err := r.Cookie("state")
-		if err != nil {
-			http.Error(w, "state not found", http.StatusBadRequest)
-			return
-		}
-		if r.URL.Query().Get("state") != state.Value {
-			http.Error(w, "state did not match", http.StatusBadRequest)
-			return
+func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
+	if r.Method == http.MethodPost {
+		config := OIDCConfig{
+			ClientProvider: r.FormValue("client_provider"),
+			ClientID:       r.FormValue("client_id"),
+			ClientSecret:   r.FormValue("client_secret"),
+			Scopes:         r.FormValue("scopes"),
 		}
 
-		oauth2Token, err := config.Exchange(ctx, r.URL.Query().Get("code"))
-		if err != nil {
-			http.Error(w, "Failed to exchange token: "+err.Error(), http.StatusInternalServerError)
-			return
-		}
-		rawIDToken, ok := oauth2Token.Extra("id_token").(string)
-		if !ok {
-			http.Error(w, "No id_token field in oauth2 token.", http.StatusInternalServerError)
-			return
-		}
-		idToken, err := verifier.Verify(ctx, rawIDToken)
-		if err != nil {
-			http.Error(w, "Failed to verify ID Token: "+err.Error(), http.StatusInternalServerError)
+		if config.ClientProvider == "" || config.ClientID == "" {
+			http.Error(w, "Client provider and client ID are required", http.StatusBadRequest)
 			return
 		}
 
-		nonce, err := r.Cookie("nonce")
-		if err != nil {
-			http.Error(w, "nonce not found", http.StatusBadRequest)
-			return
-		}
-		if idToken.Nonce != nonce.Value {
-			http.Error(w, "nonce did not match", http.StatusBadRequest)
+		if err := s.updateConfig(r.Context(), &config); err != nil {
+			http.Error(w, err.Error(), http.StatusBadRequest)
 			return
 		}
 
-		userInfo, err := provider.UserInfo(ctx, oauth2.StaticTokenSource(oauth2Token))
-		if err != nil {
-			http.Error(w, "Failed to get userinfo: "+err.Error(), http.StatusInternalServerError)
-			return
-		}
+		http.Redirect(w, r, "/auth", http.StatusFound)
+		return
+	}
 
-		resp := struct {
-			OAuth2Token   *oauth2.Token    `json:"oauth2_token"`
-			IDTokenClaims *json.RawMessage `json:"claims"`
-			UserInfo      *oidc.UserInfo   `json:"user_info"`
-		}{
-			OAuth2Token:   oauth2Token,
-			IDTokenClaims: new(json.RawMessage),
-			UserInfo:      userInfo,
-		}
+	indexTmpl.Execute(w, IndexContext{
+		Issuer:       s.args.clientProvider,
+		ClientID:     s.args.clientID,
+		ClientSecret: s.args.clientSecret,
+		Scopes:       s.args.scopes,
+		RedirectURI:  s.args.redirect(),
+	})
+}
+
+func (s *Server) handleAuth(w http.ResponseWriter, r *http.Request) {
+	config := s.oauth2Config
 
-		if err := idToken.Claims(&resp.IDTokenClaims); err != nil {
-			http.Error(w, err.Error(), http.StatusInternalServerError)
-			return
+	if config == nil {
+		http.Error(w, "OIDC not configured", http.StatusBadRequest)
+		return
+	}
+
+	state, err := randString(16)
+	if err != nil {
+		http.Error(w, "Internal error", http.StatusInternalServerError)
+		return
+	}
+	nonce, err := randString(16)
+	if err != nil {
+		http.Error(w, "Internal error", http.StatusInternalServerError)
+		return
+	}
+	setCallbackCookie(w, r, "state", state)
+	setCallbackCookie(w, r, "nonce", nonce)
+
+	http.Redirect(w, r, config.AuthCodeURL(state, oidc.Nonce(nonce)), http.StatusFound)
+}
+
+func (s *Server) handleCallback(w http.ResponseWriter, r *http.Request) {
+	config := s.oauth2Config
+	provider := s.provider
+	verifier := s.verifier
+
+	if config == nil || provider == nil || verifier == nil {
+		http.Error(w, "OIDC not configured", http.StatusBadRequest)
+		return
+	}
+
+	state, err := r.Cookie("state")
+	if err != nil {
+		http.Error(w, "state not found", http.StatusBadRequest)
+		return
+	}
+	if r.URL.Query().Get("state") != state.Value {
+		http.Error(w, "state did not match", http.StatusBadRequest)
+		return
+	}
+
+	oauth2Token, err := config.Exchange(r.Context(), r.URL.Query().Get("code"))
+	if err != nil {
+		http.Error(w, "Failed to exchange token: "+err.Error(), http.StatusInternalServerError)
+		return
+	}
+	rawIDToken, ok := oauth2Token.Extra("id_token").(string)
+	if !ok {
+		http.Error(w, "No id_token field in oauth2 token.", http.StatusInternalServerError)
+		return
+	}
+	idToken, err := verifier.Verify(r.Context(), rawIDToken)
+	if err != nil {
+		http.Error(w, "Failed to verify ID Token: "+err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	nonce, err := r.Cookie("nonce")
+	if err != nil {
+		http.Error(w, "nonce not found", http.StatusBadRequest)
+		return
+	}
+	if idToken.Nonce != nonce.Value {
+		http.Error(w, "nonce did not match", http.StatusBadRequest)
+		return
+	}
+
+	userInfo, err := provider.UserInfo(r.Context(), oauth2.StaticTokenSource(oauth2Token))
+	if err != nil {
+		http.Error(w, "Failed to get userinfo: "+err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	var tokenClaims json.RawMessage
+	if err := idToken.Claims(&tokenClaims); err != nil {
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	tokenClaimsJSON, err := json.MarshalIndent(tokenClaims, "", "\t")
+	if err != nil {
+		http.Error(w, "Could not marshal token claims JSON: "+err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	userInfoJSON, err := json.MarshalIndent(userInfo, "", "\t")
+	if err != nil {
+		http.Error(w, "Could not marshal userinfo JSON: "+err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	tokenResponseJSON, err := json.MarshalIndent(oauth2Token, "", "\t")
+	if err != nil {
+		http.Error(w, "Could not marshal oauth2 token response JSON: "+err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	indexTmpl.Execute(w, IndexContext{
+		Issuer:        s.issuer,
+		ClientID:      config.ClientID,
+		ClientSecret:  config.ClientSecret,
+		Scopes:        s.scopes,
+		RedirectURI:   config.RedirectURL,
+		Results:       true,
+		TokenClaims:   string(tokenClaimsJSON),
+		UserInfo:      string(userInfoJSON),
+		TokenResponse: string(tokenResponseJSON),
+	})
+}
+
+func main() {
+	var args args
+	fs := flag.NewFlagSet("oidc", flag.ExitOnError)
+	fs.StringVar(&args.clientProvider, "client-provider", "", "Default client provider (e.g. https://accounts.google.com)")
+	fs.StringVar(&args.clientID, "client-id", "", "Default client ID")
+	fs.StringVar(&args.clientSecret, "client-secret", "", "Default client secret")
+	fs.IntVar(&args.port, "port", 8000, "Port to run on")
+	fs.StringVar(&args.scopes, "scopes", "profile email", "Default scopes")
+	fs.StringVar(&args.origin, "origin", "http://localhost:8000", "Web origin")
+	fs.String("config", ".env", "Env config")
+	if err := ff.Parse(fs, os.Args[1:],
+		ff.WithEnvVarPrefix("OIDC"),
+		ff.WithConfigFileFlag("config"),
+		ff.WithAllowMissingConfigFile(true),
+		ff.WithConfigFileParser(ff.EnvParser),
+	); err != nil {
+		log.Fatal(err)
+	}
+
+	server := &Server{
+		args: args,
+	}
+
+	if args.clientProvider != "" && args.clientID != "" {
+		defaultConfig := &OIDCConfig{
+			ClientProvider: args.clientProvider,
+			ClientID:       args.clientID,
+			ClientSecret:   args.clientSecret,
+			Scopes:         args.scopes,
 		}
-		w.Header().Set("Content-Type", "application/json")
-		enc := json.NewEncoder(w)
-		enc.SetIndent("", "\t")
-		if err := enc.Encode(resp); err != nil {
-			http.Error(w, err.Error(), http.StatusInternalServerError)
+		if err := server.updateConfig(context.Background(), defaultConfig); err != nil {
+			log.Printf("Warning: Failed to initialize default config: %v", err)
 		}
-	})
+	}
+
+	mux := http.NewServeMux()
+	mux.HandleFunc("/", server.handleIndex)
+	mux.Handle("/_/", http.StripPrefix("/_/", http.FileServerFS(staticFiles)))
+	mux.HandleFunc("/auth", server.handleAuth)
+	mux.HandleFunc("/callback", server.handleCallback)
 
 	bind := fmt.Sprintf(":%d", args.port)
 	log.Println("listening on http://localhost" + bind)
I static/index.gotmpl
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
diff --git a/static/index.gotmpl b/static/index.gotmpl
new file mode 100644
index 0000000000000000000000000000000000000000..c979f0f983701a229901dfe5f8630819b107178e
--- /dev/null
+++ b/static/index.gotmpl
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>OIDC Playground</title>
+  <link rel="stylesheet" href="/_/styles.css">
+  <link rel="stylesheet" href="/_/prism.css">
+</head>
+
+<body>
+  <div class="container">
+    <h1>OIDC Playground</h1>
+
+    <div class="section">
+      <h2>Configuration</h2>
+      <form id="oidc-form" method="POST" action="/">
+        <div class="form-group">
+          <label for="issuer">Issuer URL:</label>
+          <input type="url" id="issuer" name="client_provider" required
+            placeholder="https://example.com/auth/realms/master" value="{{ .Issuer }}">
+        </div>
+
+        <div class="form-group">
+          <label for="client-id">Client ID:</label>
+          <input type="text" id="client-id" name="client_id" required placeholder="your-client-id" value="{{ .ClientID }}">
+        </div>
+
+        <div class="form-group">
+          <label for="client-secret">Client Secret:</label>
+          <input type="password" id="client-secret" name="client_secret"
+            placeholder="your-client-secret (optional for public clients)" value="{{ .ClientSecret }}">
+        </div>
+
+        <div class="form-group">
+          <label for="scopes">Scopes:</label>
+          <input type="text" id="scopes" name="scopes" value="openid profile email" placeholder="openid profile email" value="{{ .Scopes }}">
+        </div>
+
+        <div class="form-group">
+          <label for="redirect-uri">Redirect URI:</label>
+          <input type="url" id="redirect-uri" style="user-select: all;" required readonly value="{{ .RedirectURI }}">
+        </div>
+
+        <button type="submit">Start Authentication</button>
+      </form>
+    </div>
+
+    {{ if .Results }}
+    <div class="section" id="results-section">
+      <h2>Results</h2>
+
+      <div class="result-group">
+        <h3>Token Claims</h3>
+        <pre><code id="id-token-claims" class="language-json">{{ .TokenClaims }}</code></pre>
+      </div>
+
+      <div class="result-group">
+        <h3>User Info</h3>
+        <pre><code id="user-info" class="language-json">{{ .UserInfo }}</code></pre>
+      </div>
+
+      <div class="result-group">
+        <h3>Token Response</h3>
+        <pre><code id="token-response" class="language-json">{{ .TokenResponse }}</code></pre>
+      </div>
+    </div>
+
+    <div class="section">
+      <h2>Instructions</h2>
+      <ol>
+        <li>Fill in your OIDC provider details above</li>
+        <li>Make sure your redirect URI is registered with your OIDC provider</li>
+        <li>Click "Start OIDC Flow" to begin authentication</li>
+        <li>After successful authentication, view the tokens and claims below</li>
+      </ol>
+
+    </div>
+  </div>  
+  {{ end }}
+
+  <script src="/_/script.js"></script>
+  <script src="/_/prism.js"></script>
+</body>
+
+</html>
I static/prism.css
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
diff --git a/static/prism.css b/static/prism.css
new file mode 100644
index 0000000000000000000000000000000000000000..d5c6a03f0f415086ee0c4cd9a8dbe86ff009f9bd
--- /dev/null
+++ b/static/prism.css
@@ -0,0 +1,137 @@
+/* PrismJS 1.30.0
+https://prismjs.com/download#themes=prism&languages=json */
+code[class*=language-],
+pre[class*=language-] {
+  color: #000;
+  background: 0 0;
+  text-shadow: 0 1px #fff;
+  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
+  font-size: 1em;
+  text-align: left;
+  white-space: pre;
+  word-spacing: normal;
+  word-break: normal;
+  word-wrap: normal;
+  line-height: 1.5;
+  -moz-tab-size: 4;
+  -o-tab-size: 4;
+  tab-size: 4;
+  -webkit-hyphens: none;
+  -moz-hyphens: none;
+  -ms-hyphens: none;
+  hyphens: none
+}
+
+code[class*=language-] ::-moz-selection,
+code[class*=language-]::-moz-selection,
+pre[class*=language-] ::-moz-selection,
+pre[class*=language-]::-moz-selection {
+  text-shadow: none;
+  background: #b3d4fc
+}
+
+code[class*=language-] ::selection,
+code[class*=language-]::selection,
+pre[class*=language-] ::selection,
+pre[class*=language-]::selection {
+  text-shadow: none;
+  background: #b3d4fc
+}
+
+@media print {
+
+  code[class*=language-],
+  pre[class*=language-] {
+    text-shadow: none
+  }
+}
+
+pre[class*=language-] {
+  padding: 1em;
+  margin: .5em 0;
+  overflow: auto
+}
+
+:not(pre)>code[class*=language-],
+pre[class*=language-] {
+  background: #f5f2f0
+}
+
+:not(pre)>code[class*=language-] {
+  padding: .1em;
+  border-radius: .3em;
+  white-space: normal
+}
+
+.token.cdata,
+.token.comment,
+.token.doctype,
+.token.prolog {
+  color: #708090
+}
+
+.token.punctuation {
+  color: #999
+}
+
+.token.namespace {
+  opacity: .7
+}
+
+.token.boolean,
+.token.constant,
+.token.deleted,
+.token.number,
+.token.property,
+.token.symbol,
+.token.tag {
+  color: #905
+}
+
+.token.attr-name,
+.token.builtin,
+.token.char,
+.token.inserted,
+.token.selector,
+.token.string {
+  color: #690
+}
+
+.language-css .token.string,
+.style .token.string,
+.token.entity,
+.token.operator,
+.token.url {
+  color: #9a6e3a;
+  background: hsla(0, 0%, 100%, .5)
+}
+
+.token.atrule,
+.token.attr-value,
+.token.keyword {
+  color: #07a
+}
+
+.token.class-name,
+.token.function {
+  color: #dd4a68
+}
+
+.token.important,
+.token.regex,
+.token.variable {
+  color: #e90
+}
+
+.token.bold,
+.token.important {
+  font-weight: 700
+}
+
+.token.italic {
+  font-style: italic
+}
+
+.token.entity {
+  cursor: help
+}
\ No newline at end of file
I static/prism.js
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
diff --git a/static/prism.js b/static/prism.js
new file mode 100644
index 0000000000000000000000000000000000000000..18e6d92482ab804bdf02d0343a0afddb0911394b
--- /dev/null
+++ b/static/prism.js
@@ -0,0 +1,7 @@
+
+
+/* PrismJS 1.30.0
+https://prismjs.com/download#themes=prism&languages=json */
+var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(e){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,r={},a={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof i?new i(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++t}),e.__id},clone:function e(n,t){var r,i;switch(t=t||{},a.util.type(n)){case"Object":if(i=a.util.objId(n),t[i])return t[i];for(var l in r={},t[i]=r,n)n.hasOwnProperty(l)&&(r[l]=e(n[l],t));return r;case"Array":return i=a.util.objId(n),t[i]?t[i]:(r=[],t[i]=r,n.forEach((function(n,a){r[a]=e(n,t)})),r);default:return n}},getLanguage:function(e){for(;e;){var t=n.exec(e.className);if(t)return t[1].toLowerCase();e=e.parentElement}return"none"},setLanguage:function(e,t){e.className=e.className.replace(RegExp(n,"gi"),""),e.classList.add("language-"+t)},currentScript:function(){if("undefined"==typeof document)return null;if(document.currentScript&&"SCRIPT"===document.currentScript.tagName)return document.currentScript;try{throw new Error}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var n=document.getElementsByTagName("script");for(var t in n)if(n[t].src==e)return n[t]}return null}},isActive:function(e,n,t){for(var r="no-"+n;e;){var a=e.classList;if(a.contains(n))return!0;if(a.contains(r))return!1;e=e.parentElement}return!!t}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,n){var t=a.util.clone(a.languages[e]);for(var r in n)t[r]=n[r];return t},insertBefore:function(e,n,t,r){var i=(r=r||a.languages)[e],l={};for(var o in i)if(i.hasOwnProperty(o)){if(o==n)for(var s in t)t.hasOwnProperty(s)&&(l[s]=t[s]);t.hasOwnProperty(o)||(l[o]=i[o])}var u=r[e];return r[e]=l,a.languages.DFS(a.languages,(function(n,t){t===u&&n!=e&&(this[n]=l)})),l},DFS:function e(n,t,r,i){i=i||{};var l=a.util.objId;for(var o in n)if(n.hasOwnProperty(o)){t.call(n,o,n[o],r||o);var s=n[o],u=a.util.type(s);"Object"!==u||i[l(s)]?"Array"!==u||i[l(s)]||(i[l(s)]=!0,e(s,t,o,i)):(i[l(s)]=!0,e(s,t,null,i))}}},plugins:{},highlightAll:function(e,n){a.highlightAllUnder(document,e,n)},highlightAllUnder:function(e,n,t){var r={callback:t,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};a.hooks.run("before-highlightall",r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),a.hooks.run("before-all-elements-highlight",r);for(var i,l=0;i=r.elements[l++];)a.highlightElement(i,!0===n,r.callback)},highlightElement:function(n,t,r){var i=a.util.getLanguage(n),l=a.languages[i];a.util.setLanguage(n,i);var o=n.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&a.util.setLanguage(o,i);var s={element:n,language:i,grammar:l,code:n.textContent};function u(e){s.highlightedCode=e,a.hooks.run("before-insert",s),s.element.innerHTML=s.highlightedCode,a.hooks.run("after-highlight",s),a.hooks.run("complete",s),r&&r.call(s.element)}if(a.hooks.run("before-sanity-check",s),(o=s.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!s.code)return a.hooks.run("complete",s),void(r&&r.call(s.element));if(a.hooks.run("before-highlight",s),s.grammar)if(t&&e.Worker){var c=new Worker(a.filename);c.onmessage=function(e){u(e.data)},c.postMessage(JSON.stringify({language:s.language,code:s.code,immediateClose:!0}))}else u(a.highlight(s.code,s.grammar,s.language));else u(a.util.encode(s.code))},highlight:function(e,n,t){var r={code:e,grammar:n,language:t};if(a.hooks.run("before-tokenize",r),!r.grammar)throw new Error('The language "'+r.language+'" has no grammar.');return r.tokens=a.tokenize(r.code,r.grammar),a.hooks.run("after-tokenize",r),i.stringify(a.util.encode(r.tokens),r.language)},tokenize:function(e,n){var t=n.rest;if(t){for(var r in t)n[r]=t[r];delete n.rest}var a=new s;return u(a,a.head,e),o(e,a,n,a.head,0),function(e){for(var n=[],t=e.head.next;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=a.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=a.hooks.all[e];if(t&&t.length)for(var r,i=0;r=t[i++];)r(n)}},Token:i};function i(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function l(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function o(e,n,t,r,s,g){for(var f in t)if(t.hasOwnProperty(f)&&t[f]){var h=t[f];h=Array.isArray(h)?h:[h];for(var d=0;d<h.length;++d){if(g&&g.cause==f+","+d)return;var v=h[d],p=v.inside,m=!!v.lookbehind,y=!!v.greedy,k=v.alias;if(y&&!v.pattern.global){var x=v.pattern.toString().match(/[imsuy]*$/)[0];v.pattern=RegExp(v.pattern.source,x+"g")}for(var b=v.pattern||v,w=r.next,A=s;w!==n.tail&&!(g&&A>=g.reach);A+=w.value.length,w=w.next){var P=w.value;if(n.length>e.length)return;if(!(P instanceof i)){var E,S=1;if(y){if(!(E=l(b,A,e,m))||E.index>=e.length)break;var L=E.index,O=E.index+E[0].length,C=A;for(C+=w.value.length;L>=C;)C+=(w=w.next).value.length;if(A=C-=w.value.length,w.value instanceof i)continue;for(var j=w;j!==n.tail&&(C<O||"string"==typeof j.value);j=j.next)S++,C+=j.value.length;S--,P=e.slice(A,C),E.index-=A}else if(!(E=l(b,0,P,m)))continue;L=E.index;var N=E[0],_=P.slice(0,L),M=P.slice(L+N.length),W=A+P.length;g&&W>g.reach&&(g.reach=W);var I=w.prev;if(_&&(I=u(n,I,_),A+=_.length),c(n,I,S),w=u(n,I,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),S>1){var T={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,T),g&&T.reach>g.reach&&(g.reach=T.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a<t&&r!==e.tail;a++)r=r.next;n.next=r,r.prev=n,e.length-=a}if(e.Prism=a,i.stringify=function e(n,t){if("string"==typeof n)return n;if(Array.isArray(n)){var r="";return n.forEach((function(n){r+=e(n,t)})),r}var i={type:n.type,content:e(n.content,t),tag:"span",classes:["token",n.type],attributes:{},language:t},l=n.alias;l&&(Array.isArray(l)?Array.prototype.push.apply(i.classes,l):i.classes.push(l)),a.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=" "+s+'="'+(i.attributes[s]||"").replace(/"/g,"&quot;")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'"'+o+">"+i.content+"</"+i.tag+">"},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
+Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json;
+
I static/script.js
1
2
3
4
5
6
7
8
9
diff --git a/static/script.js b/static/script.js
new file mode 100644
index 0000000000000000000000000000000000000000..62d4dd54d7237df67ed72e151c64350702b68d56
--- /dev/null
+++ b/static/script.js
@@ -0,0 +1,3 @@
+document.addEventListener('DOMContentLoaded', () => {
+    document.getElementById('results-section').scrollIntoView({ behavior: 'smooth' });
+});
I static/styles.css
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
diff --git a/static/styles.css b/static/styles.css
new file mode 100644
index 0000000000000000000000000000000000000000..bb26677a92597f0db520c85e7ce3eed564dd29ed
--- /dev/null
+++ b/static/styles.css
@@ -0,0 +1,140 @@
+* {
+  margin: 0;
+  padding: 0;
+  box-sizing: border-box;
+}
+
+body {
+  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
+  line-height: 1.6;
+  color: #333;
+  background-color: #f5f5f5;
+}
+
+.container {
+  max-width: 800px;
+  margin: 0 auto;
+  padding: 20px;
+}
+
+h1 {
+  text-align: center;
+  margin-bottom: 30px;
+  color: #2c3e50;
+}
+
+.section {
+  background: white;
+  margin-bottom: 20px;
+  padding: 20px;
+  border-radius: 8px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+}
+
+.section h2 {
+  margin-bottom: 15px;
+  color: #34495e;
+  border-bottom: 2px solid #3498db;
+  padding-bottom: 5px;
+}
+
+.form-group {
+  margin-bottom: 15px;
+}
+
+.form-group label {
+  display: block;
+  margin-bottom: 5px;
+  font-weight: 600;
+  color: #555;
+}
+
+.form-group input {
+  width: 100%;
+  padding: 10px;
+  border: 1px solid #ddd;
+  border-radius: 4px;
+  font-size: 14px;
+}
+
+.form-group input:focus {
+  outline: none;
+  border-color: #3498db;
+  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
+}
+
+.form-group input[readonly] {
+  background-color: #f8f9fa;
+  color: #6c757d;
+}
+
+
+button {
+  background-color: #3498db;
+  color: white;
+  padding: 12px 24px;
+  border: none;
+  border-radius: 4px;
+  font-size: 16px;
+  cursor: pointer;
+  transition: background-color 0.3s;
+}
+
+button:hover {
+  background-color: #2980b9;
+}
+
+button:disabled {
+  background-color: #bdc3c7;
+  cursor: not-allowed;
+}
+
+.result-group {
+  margin-bottom: 20px;
+}
+
+.result-group h3 {
+  margin-bottom: 10px;
+  color: #2c3e50;
+}
+
+.result-group textarea {
+  width: 100%;
+  min-height: 100px;
+  padding: 10px;
+  border: 1px solid #ddd;
+  border-radius: 4px;
+  font-family: 'Courier New', monospace;
+  font-size: 12px;
+  resize: vertical;
+}
+
+.result-group pre {
+  background-color: #f8f9fa;
+  padding: 15px;
+  border-radius: 4px;
+  border: 1px solid #e9ecef;
+  font-family: 'Courier New', monospace;
+  font-size: 12px;
+  overflow-x: auto;
+  white-space: pre-wrap;
+  word-wrap: break-word;
+}
+
+ol {
+  padding-left: 20px;
+}
+
+ol li {
+  margin-bottom: 5px;
+}
+
+@media (max-width: 600px) {
+  .container {
+    padding: 10px;
+  }
+
+  .section {
+    padding: 15px;
+  }
+}
\ No newline at end of file