-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmock-saml-idp.html
More file actions
852 lines (784 loc) · 53.6 KB
/
mock-saml-idp.html
File metadata and controls
852 lines (784 loc) · 53.6 KB
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mock SAML IdP for Elasticsearch and Kibana SSO | Secutils.dev</title>
<meta name="description" content="Generate signed SAML responses for testing Elasticsearch and Kibana SSO. IdP-initiated and SP-initiated flows. Configurable users, roles, attributes. No signup.">
<meta name="robots" content="noindex, nofollow">
<link rel="canonical" href="https://{{TOOLS_HOST}}/elastic/saml/idp-login">
<meta name="su-tool-path" content="/elastic/saml/idp-login">
<meta name="su-tool-name" content="Mock SAML IdP">
<meta name="su-tool-description" content="Generate signed SAML responses for ES/Kibana SSO testing. IdP- and SP-initiated flows, configurable users, roles, and attributes.">
<meta name="su-tool-promote" content="false">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Secutils.dev">
<meta property="og:title" content="Mock SAML IdP for Elasticsearch & Kibana SSO">
<meta property="og:description" content="Generate signed SAML responses for testing Elasticsearch and Kibana SSO. IdP-initiated and SP-initiated flows.">
<meta property="og:url" content="https://{{TOOLS_HOST}}/elastic/saml/idp-login">
<meta property="og:image" content="https://secutils.dev/docs/img/og/og-mock-saml-idp.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Mock SAML IdP on Secutils.dev: signed SAML responses for ES/Kibana SSO testing.">
<meta property="og:locale" content="en_US">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Mock SAML IdP for Elasticsearch & Kibana SSO">
<meta name="twitter:description" content="Generate signed SAML responses for testing Elasticsearch and Kibana SSO. IdP- and SP-initiated flows. No signup.">
<meta name="twitter:image" content="https://secutils.dev/docs/img/og/og-mock-saml-idp.png">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebApplication","name":"Mock SAML IdP","url":"https://{{TOOLS_HOST}}/elastic/saml/idp-login","applicationCategory":"SecurityApplication","operatingSystem":"Any","browserRequirements":"Requires JavaScript","isAccessibleForFree":true,"offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"publisher":{"@type":"Organization","name":"Secutils.dev","url":"https://secutils.dev"},"sameAs":"https://github.com/secutils-dev/secutils/blob/main/dev/tools/mock-saml-idp.html","description":"Generate signed SAML responses for testing Elasticsearch and Kibana SSO. Supports IdP-initiated and SP-initiated flows with configurable users, roles, and attributes. Browser-only, no signup."}</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsrsasign/10.9.0/jsrsasign-all-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300..700&family=Roboto+Mono:wght@400..700&display=swap" rel="stylesheet">
<!-- Privacy-friendly analytics by Plausible -->
<script defer src="https://tools.secutils.dev/js/script.js"></script>
<script>
window.plausible = window.plausible || function () { (plausible.q = plausible.q || []).push(arguments) };
plausible.init = plausible.init || function (i) { plausible.o = i || {} };
plausible.init();
</script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root, [data-theme="dark"] {
--bg: #141519; --surface: #1d1e24; --surface-hover: #2c2d33;
--border: #343741; --text: #dfe5ef; --text-muted: #98a2b3;
--primary: #fed047; --primary-hover: #fdc615;
--primary-text: #642340;
--primary-glow: rgba(254,208,71,0.10);
--accent: #642340;
--badge-bg: #2B394F; --badge-text: #98A8C3;
--input-bg: #16171c; --input-border: #343741;
--card-bg: rgba(29,30,36,0.7);
--info-bg: rgba(43,57,79,0.3); --info-border: rgba(43,57,79,0.6); --info-text: #98A8C3;
--tab-active-bg: var(--primary); --tab-active-text: var(--primary-text);
--font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
--mono: 'Roboto Mono', 'SF Mono', 'Fira Code', Consolas, monospace;
}
[data-theme="light"] {
--bg: #f5f7fa; --surface: #ffffff; --surface-hover: #f1f3f5;
--border: #d3dae6; --text: #343741; --text-muted: #69707d;
--primary: #fed047; --primary-hover: #fdc615;
--primary-text: #642340;
--primary-glow: rgba(254,208,71,0.15);
--accent: #642340;
--badge-bg: #E3E8F2; --badge-text: #505F79;
--input-bg: #ffffff; --input-border: #d3dae6;
--card-bg: #ffffff;
--info-bg: rgba(227,232,242,0.5); --info-border: #d3dae6; --info-text: #505F79;
--tab-active-bg: var(--primary); --tab-active-text: var(--primary-text);
}
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; transition: background .25s, color .25s; }
header { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; height: 48px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; transition: background .25s, border-color .25s; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-svg { flex-shrink: 0; }
.logo-svg .logo-text-fill { fill: var(--text); }
.logo-badge { display: inline-flex; align-items: center; padding: 4px 16px; border-radius: 4px; border: none; background: var(--badge-bg); color: var(--badge-text); font-size: 12px; font-weight: 450; line-height: 16px; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 8px; }
.theme-toggle { width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; transition: all .2s; }
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.skill-link { height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text-muted); font: 12px var(--font, system-ui), sans-serif; text-decoration: none; transition: all .15s; cursor: pointer; }
.skill-link:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface-hover); }
.skill-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; }
.su-related { max-width: 760px; margin: 24px auto 0; padding: 0 16px 8px; font-family: var(--font, system-ui), sans-serif; }
.su-related-title { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 10px; }
.su-related-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.su-related-list li a { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .8rem; line-height: 1.4; text-decoration: none; transition: background .15s, border-color .15s; }
.su-related-list li a:hover { background: var(--surface-hover); border-color: var(--text-muted); }
.su-related-list li a strong { color: var(--text); font-weight: 600; }
.su-related-all a { background: transparent !important; border-style: dashed !important; text-align: center; }
.su-noscript { max-width: 720px; margin: 24px auto; padding: 16px; border: 1px solid var(--border); border-radius: 8px; font: 14px/1.5 var(--font, system-ui), sans-serif; background: var(--surface); color: var(--text); }
main { flex: 1; padding: 32px 16px; display: flex; justify-content: center; }
.card { width: 100%; max-width: 640px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 24px rgba(0,0,0,0.15); }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { flex: 1; padding: 12px 16px; font: 500 13px/1 var(--font); border: none; cursor: pointer; transition: all .15s; background: transparent; color: var(--text-muted); }
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab.active { background: var(--tab-active-bg); color: var(--tab-active-text); font-weight: 600; }
.card-body { padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-input { width: 100%; padding: 8px 12px; font: 14px/1.5 var(--font); background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); border-radius: 6px; outline: none; transition: border-color .15s; }
.form-input:focus { border-color: var(--primary); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; cursor: pointer; }
/* `height` pins the outer size so `.btn-primary`'s `font-weight: 600` doesn't
render 1-2 px taller than the regular variant via expanded bold strut
metrics. This tool uses slightly larger paddings (8/6 px instead of 7/5 px)
so the pinned heights are correspondingly 31 / 26 px. `.btn-full` opts out
with `height: auto` because its 12 px padding + 14 px font intentionally
make it a taller call-to-action. See dev/tools/AGENTS.md -> "Buttons". */
.btn { padding: 8px 16px; height: 31px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 13px/1 var(--font); cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-hover); border-color: var(--text-muted); }
.btn-primary { background: var(--primary); border-color: var(--primary-text); color: var(--primary-text); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary.btn-full { width: 100%; height: auto; justify-content: center; padding: 12px; font-size: 14px; }
.btn-sm { padding: 6px 12px; height: 26px; font-size: 12px; }
.role-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 28px; }
.role-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; background: var(--badge-bg); border-radius: 4px; font-size: 13px; color: var(--badge-text); }
.role-tag button { display: flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: none; background: transparent; color: var(--text-muted); cursor: pointer; transition: all .15s; padding: 0; }
.role-tag button:hover { background: var(--surface-hover); color: var(--text); }
.flex-row { display: flex; gap: 8px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-6 { margin-top: 24px; }
.info-banner { padding: 10px 14px; background: var(--info-bg); border: 1px solid var(--info-border); border-radius: 6px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--info-text); }
.info-banner svg { flex-shrink: 0; }
.info-banner code { background: var(--input-bg); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); font-size: 12px; }
.info-banner strong { font-weight: 600; }
.status-box { font-family: var(--mono); font-size: 12px; line-height: 1.6; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 6px; padding: 14px; min-height: 100px; max-height: 300px; overflow-y: auto; color: #66bb6a; }
.status-box .text-error { color: #ef5350; }
.status-box .text-success { color: #66bb6a; }
.status-box .text-info { color: var(--text-muted); }
footer.su-footer { text-align: center; padding: 16px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }
footer.su-footer p { margin: 0; }
.su-footer-fineprint { margin-top: 6px !important; font-size: 10.5px; opacity: 0.75; }
.su-footer-link { background: none; border: none; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.su-footer-link:hover { color: var(--text); }
.su-dialog { max-width: 520px; width: calc(100% - 32px); max-height: calc(100% - 32px); inset: 0; margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.su-dialog::backdrop { background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); }
.su-dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.su-dialog-header h2 { font-size: 1rem; font-weight: 600; }
.su-dialog-close { width: 28px; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; transition: all .15s; }
.su-dialog-close:hover { background: var(--surface-hover); color: var(--text); }
.su-dialog-body { padding: 16px 18px; font-size: 0.875rem; line-height: 1.55; color: var(--text); }
.su-dialog-body p { margin-bottom: 12px; }
.su-dialog-body p:last-child { margin-bottom: 0; }
.su-dialog-body code { font-family: var(--mono); background: var(--surface-hover); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.su-dialog-body a { color: var(--primary); text-decoration: none; }
.su-dialog-body a:hover { text-decoration: underline; }
.su-dialog-fineprint { font-size: 0.8rem; color: var(--text-muted); }
.su-credits-list { margin: 0 0 12px; padding-left: 20px; }
.su-credits-list li { margin-bottom: 6px; }
.su-credits-list li:last-child { margin-bottom: 0; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
@media (max-width: 640px) {
header { padding: 0 12px; }
.logo-svg { height: 20px; }
.logo-badge { font-size: 11px; padding: 2px 7px; }
main { padding: 16px; }
.card-body { padding: 16px; }
}
</style>
</head>
<body>
<noscript>
<p class="su-noscript"><strong>Mock SAML IdP</strong> — Generate signed SAML responses for testing Elasticsearch and Kibana SSO. Configurable users, roles, attributes. Requires JavaScript; please enable it. Source on <a href="https://github.com/secutils-dev/secutils/blob/main/dev/tools/mock-saml-idp.html">GitHub</a>.</p>
</noscript>
<header>
<a class="logo" href="https://secutils.dev" target="_blank" rel="noopener">
<svg class="logo-svg" height="24" role="img" viewBox="0 0 98 16" xmlns="http://www.w3.org/2000/svg">
<path d="m3 0h10c1.662 0 3 1.338 3 3v10c0 1.662-1.338 3-3 3h-10c-1.662 0-3-1.338-3-3v-10c0-1.662 1.338-3 3-3z" fill="#fed047"/>
<path aria-label="SU" d="m11.285 12q-1.12 0-1.728-0.608-0.608-0.61867-0.608-1.6747v-5.6107h1.152v5.6q0 0.59733 0.29867 0.93867 0.29867 0.34133 0.88534 0.34133 0.58667 0 0.88534-0.34133 0.29867-0.34134 0.29867-0.93867v-5.6h1.152v5.6107q0 1.0667-0.608 1.6747t-1.728 0.608zm-6.368 0q-1.152 0-1.8453-0.608-0.69334-0.608-0.69334-1.664h1.1307q0 0.58667 0.384 0.928 0.384 0.33067 1.024 0.33067 0.62934 0 0.992-0.34133 0.36267-0.34134 0.36267-0.90667 0-0.42667-0.23467-0.74667t-0.672-0.43733l-1.12-0.29867q-0.78934-0.21333-1.248-0.77867-0.448-0.56534-0.448-1.3547 0-0.64 0.27733-1.1093 0.288-0.48 0.81067-0.74667t1.216-0.26667 1.216 0.26667q0.53334 0.26667 0.82134 0.74667 0.29867 0.46933 0.29867 1.0987h-1.1307q0-0.50133-0.34133-0.8-0.33067-0.30933-0.864-0.30933t-0.864 0.30933q-0.32 0.29867-0.32 0.78934 0 0.39467 0.21333 0.66134 0.224 0.26667 0.61867 0.37333l1.152 0.30933q0.81067 0.21333 1.28 0.832t0.46933 1.4613q0 0.69334-0.30933 1.2053-0.30933 0.50133-0.864 0.77867-0.55467 0.27733-1.312 0.27733z" fill="#642340"/>
<path class="logo-text-fill" aria-label="SECUTILS.DEV" d="m93.158 12.117-1.9733-7.7867h1.1733l1.2587 5.184q0.11733 0.46933 0.20267 0.91734 0.08533 0.448 0.128 0.69334 0.04267-0.24533 0.128-0.69334 0.096-0.45867 0.21333-0.928l1.2053-5.1733h1.184l-1.984 7.7867zm-7.8294 0v-7.7867h4.576v1.024h-3.4453v2.2187h3.072v0.992h-3.072v2.528h3.4453v1.024zm-6.5174 0v-7.7867h2.176q0.768 0 1.3333 0.29867 0.56534 0.288 0.87467 0.832 0.32 0.53334 0.32 1.248v3.008q0 0.736-0.32 1.2693-0.30933 0.53334-0.87467 0.832-0.56534 0.29867-1.3333 0.29867zm1.152-1.0347h1.024q0.62934 0 1.0027-0.36267 0.37333-0.36267 0.37333-1.0027v-3.008q0-0.61867-0.37333-0.98134-0.37334-0.37333-1.0027-0.37333h-1.024zm-5.2374 1.1413q-0.416 0-0.68267-0.24533-0.256-0.256-0.256-0.672 0-0.416 0.256-0.672 0.26667-0.26667 0.68267-0.26667 0.416 0 0.672 0.26667 0.26667 0.256 0.26667 0.672 0 0.416-0.26667 0.672-0.256 0.24533-0.672 0.24533zm-6.368 0q-1.152 0-1.8453-0.608-0.69334-0.608-0.69334-1.664h1.1307q0 0.58667 0.384 0.928 0.384 0.33067 1.024 0.33067 0.62934 0 0.992-0.34133 0.36267-0.34134 0.36267-0.90667 0-0.42667-0.23467-0.74667t-0.672-0.43733l-1.12-0.29867q-0.78934-0.21333-1.248-0.77867-0.448-0.56534-0.448-1.3547 0-0.64 0.27733-1.1093 0.288-0.48 0.81067-0.74667 0.52267-0.26667 1.216-0.26667 0.69334 0 1.216 0.26667 0.53334 0.26667 0.82134 0.74667 0.29867 0.46933 0.29867 1.0987h-1.1307q0-0.50134-0.34133-0.8-0.33067-0.30933-0.864-0.30933t-0.864 0.30933q-0.32 0.29867-0.32 0.78934 0 0.39467 0.21333 0.66134 0.224 0.26667 0.61867 0.37333l1.152 0.30933q0.81067 0.21333 1.28 0.832 0.46934 0.61867 0.46934 1.4613 0 0.69334-0.30934 1.2053-0.30933 0.50134-0.864 0.77867-0.55467 0.27733-1.312 0.27733zm-8.288-0.10667v-7.7867h1.152v6.7414h3.4027v1.0453zm-6.6987 0v-1.0453h1.568v-5.696h-1.568v-1.0453h4.32v1.0453h-1.5787v5.696h1.5787v1.0453zm-4.8214 0v-6.7414h-2.08v-1.0453h5.3227v1.0453h-2.0907v6.7414zm-5.824 0.10667q-1.12 0-1.728-0.608-0.608-0.61867-0.608-1.6747v-5.6107h1.152v5.6q0 0.59733 0.29867 0.93867 0.29867 0.34133 0.88534 0.34133 0.58667 0 0.88534-0.34133 0.29867-0.34134 0.29867-0.93867v-5.6h1.152v5.6107q0 1.0667-0.608 1.6747t-1.728 0.608zm-6.3147 0q-1.0987 0-1.7493-0.608-0.64-0.61867-0.64-1.664v-3.456q0-1.056 0.64-1.664 0.65067-0.608 1.7493-0.608 1.088 0 1.728 0.61867 0.65067 0.608 0.65067 1.6533h-1.152q0-0.608-0.33067-0.928-0.32-0.32-0.896-0.32-0.58667 0-0.91734 0.32-0.32 0.32-0.32 0.928v3.456q0 0.608 0.32 0.928 0.33067 0.32 0.91734 0.32 0.576 0 0.896-0.32 0.33067-0.32 0.33067-0.928h1.152q0 1.0453-0.65067 1.664-0.64 0.608-1.728 0.608zm-8.6827-0.10667v-7.7867h4.576v1.024h-3.4453v2.2187h3.072v0.992h-3.072v2.528h3.4453v1.024zm-4.1707 0.10667q-1.152 0-1.8453-0.608-0.69334-0.608-0.69334-1.664h1.1307q0 0.58667 0.384 0.928 0.384 0.33067 1.024 0.33067 0.62934 0 0.992-0.34133 0.36267-0.34134 0.36267-0.90667 0-0.42667-0.23467-0.74667-0.23467-0.32-0.672-0.43733l-1.12-0.29867q-0.78934-0.21333-1.248-0.77867-0.448-0.56534-0.448-1.3547 0-0.64 0.27733-1.1093 0.288-0.48 0.81067-0.74667 0.52267-0.26667 1.216-0.26667 0.69334 0 1.216 0.26667 0.53334 0.26667 0.82134 0.74667 0.29867 0.46933 0.29867 1.0987h-1.1307q0-0.50134-0.34134-0.8-0.33067-0.30933-0.864-0.30933t-0.864 0.30933q-0.32 0.29867-0.32 0.78934 0 0.39467 0.21333 0.66134 0.224 0.26667 0.61867 0.37333l1.152 0.30933q0.81067 0.21333 1.28 0.832 0.46934 0.61867 0.46934 1.4613 0 0.69334-0.30934 1.2053-0.30933 0.50134-0.864 0.77867-0.55467 0.27733-1.312 0.27733z"/>
</svg>
<span class="logo-badge">Mock SAML IdP</span>
</a>
<div class="header-right">
<a id="skillLink" class="skill-link" href="#" target="_blank" rel="noopener"
title="View AI agent skill (skill.md, opens in new tab)"
aria-label="View AI agent skill (opens in new tab)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.582a.5.5 0 0 1 0 .962L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>
<path d="M20 3v4"/><path d="M22 5h-4"/><path d="M4 17v2"/><path d="M5 18H3"/>
</svg>
<span>Skill</span>
</a>
<button class="theme-toggle" id="themeToggle" aria-label="Toggle theme">
<svg class="icon-sun" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M8.5 15h-1v-2h1v2Zm-3.674-3.107-1.414 1.414-.707-.707 1.414-1.415.707.708Zm8.479.707-.707.707-1.414-1.414.707-.708 1.414 1.415Z"/><path fill-rule="evenodd" d="M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Zm0 1a3 3 0 1 0 0 6 3 3 0 0 0 0-6Z" clip-rule="evenodd"/><path d="M3.005 8.505h-2v-1h2v1Zm12 0h-2v-1h2v1ZM4.82 4.114l-.708.707-1.414-1.414.707-.707L4.82 4.114Zm8.492-.707-1.414 1.414-.708-.707L12.605 2.7l.707.707ZM8.5 3h-1V1h1v2Z"/></svg>
<svg class="icon-moon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4.05 12.95A6.982 6.982 0 0 1 2 8c0-1.79.684-3.583 2.05-4.95A6.982 6.982 0 0 1 9 1a1 1 0 0 1 .708 1.707 4.982 4.982 0 0 0-1.465 3.536 4.98 4.98 0 0 0 1.465 3.535 4.98 4.98 0 0 0 3.535 1.465 1 1 0 0 1 .707 1.707A6.981 6.981 0 0 1 9 15a6.983 6.983 0 0 1-4.95-2.05Zm.708-.707A5.983 5.983 0 0 0 9 14c1.535 0 3.07-.586 4.242-1.757a5.98 5.98 0 0 1-4.018-1.545L9 10.485a5.982 5.982 0 0 1-1.758-4.242A5.986 5.986 0 0 1 9 2a5.983 5.983 0 0 0-4.243 1.757A5.98 5.98 0 0 0 3 8l.006.288a5.978 5.978 0 0 0 1.75 3.955Z"/></svg>
</button>
</div>
</header>
<main>
<div class="card">
<div class="tabs">
<button class="tab active" id="simpleModeBtn">Simple Mode</button>
<button class="tab" id="advancedModeBtn">Advanced Mode</button>
</div>
<div class="card-body">
<form id="samlForm">
<div class="form-group">
<label class="form-label">Username</label>
<input type="text" id="username" value="test_user" required class="form-input">
</div>
<div class="form-group">
<label class="form-label">Full Name</label>
<input type="text" id="fullname" value="Test User" class="form-input">
</div>
<div class="form-group">
<label class="form-label">Email</label>
<input type="email" id="email" value="test_user@elastic.co" class="form-input">
</div>
<div class="form-group">
<label class="form-label">Roles</label>
<div id="selectedRoles" class="role-tags"></div>
<select id="roleSelect" class="form-input">
<option value="">Select a role...</option>
<option value="viewer">viewer</option>
<option value="editor">editor</option>
<option value="admin">admin</option>
<option value="superuser">superuser</option>
<option value="kibana_admin">kibana_admin</option>
<option value="__custom__">+ Add custom role...</option>
</select>
<div id="customRoleInput" class="hidden mt-2">
<div class="flex-row">
<input type="text" id="customRoleName" placeholder="Enter custom role name" class="form-input flex-1">
<button type="button" id="addCustomRoleBtn" class="btn btn-primary btn-sm">Add</button>
<button type="button" id="cancelCustomRoleBtn" class="btn btn-sm">Cancel</button>
</div>
</div>
</div>
<div id="destinationSection" class="form-group hidden">
<label class="form-label">Destination URL</label>
<input type="text" id="destination" value="http://localhost:5601" class="form-input">
<p class="form-hint">The Kibana host. Path will be auto-set to /api/security/saml/callback</p>
</div>
<div class="mt-6">
<button type="submit" id="submitBtn" class="btn btn-primary btn-full">Sign & Login</button>
</div>
</form>
<div id="statusSection" class="hidden mt-6">
<label class="form-label">Debug Output</label>
<div id="statusBox" class="status-box">Ready. Waiting for input...</div>
</div>
</div>
</div>
</main>
<nav class="su-related" aria-label="Related free tools">
<h2 class="su-related-title">Related free tools</h2>
<ul class="su-related-list">
<li><a href="https://{{TOOLS_HOST}}/jwt"><strong>JWT Debugger</strong> — Decode, verify, sign HMAC JWTs.</a></li>
<li><a href="https://{{TOOLS_HOST}}/saml"><strong>SAML Decoder</strong> — Inspect SAML responses, requests, metadata.</a></li>
<li><a href="https://{{TOOLS_HOST}}/pem"><strong>Certificate Decoder</strong> — Decode PEM X.509 chains.</a></li>
<li><a href="https://{{TOOLS_HOST}}/echo"><strong>HTTP Echo / Mock</strong> — Build a shareable mock HTTP response.</a></li>
<li class="su-related-all"><a href="https://{{TOOLS_HOST}}/">Browse all tools →</a></li>
</ul>
</nav>
<footer class="su-footer">
<p>Generate signed SAML responses for testing Elasticsearch/Kibana SSO.</p>
<p class="su-footer-fineprint">
<button type="button" class="su-footer-link" id="privacyOpen">Privacy</button>
<span aria-hidden="true"> · </span>
<button type="button" class="su-footer-link" id="creditsOpen">Credits</button>
</p>
</footer>
<dialog id="privacyDialog" class="su-dialog" aria-labelledby="privacyDialogTitle">
<header class="su-dialog-header">
<h2 id="privacyDialogTitle">Privacy</h2>
<button type="button" class="su-dialog-close" id="privacyClose" aria-label="Close">
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l10 10M13 3L3 13"/></svg>
</button>
</header>
<div class="su-dialog-body">
<p><strong>Your data stays in your browser.</strong> These tools run entirely client-side. Tokens, PEMs, SAML payloads, Markdown source, and mock-response bodies are never sent to the Secutils.dev server. State that needs to survive a reload (or be shared) lives in the URL fragment (<code>#…</code>), which browsers never transmit to the server.</p>
<p><strong>Anonymous usage analytics.</strong> We use <a href="https://plausible.io/" target="_blank" rel="noopener noreferrer">Plausible Analytics</a>, a privacy-first, GDPR-compliant tool, to collect aggregate usage data. No cookies, no personal data, no individual tracking. The data is limited to top pages, referral sources, visit duration, and device-class metadata (device type, OS, country, browser). Full details in the <a href="https://plausible.io/data-policy" target="_blank" rel="noopener noreferrer">Plausible Data Policy</a>.</p>
<p class="su-dialog-fineprint">See the full <a href="https://secutils.dev/privacy" target="_blank" rel="noopener noreferrer">Secutils.dev privacy policy</a> for details on the wider service.</p>
</div>
</dialog>
<dialog id="creditsDialog" class="su-dialog" aria-labelledby="creditsDialogTitle">
<header class="su-dialog-header">
<h2 id="creditsDialogTitle">Credits</h2>
<button type="button" class="su-dialog-close" id="creditsClose" aria-label="Close">
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l10 10M13 3L3 13"/></svg>
</button>
</header>
<div class="su-dialog-body">
<p>This tool is powered by the following open-source libraries:</p>
<ul class="su-credits-list">
<li><a href="https://github.com/kjur/jsrsasign" target="_blank" rel="noopener noreferrer"><strong>jsrsasign</strong></a> - pure-JavaScript crypto toolkit, used to sign the generated SAML responses with the supplied IdP private key.</li>
<li><a href="https://github.com/nodeca/pako" target="_blank" rel="noopener noreferrer"><strong>pako</strong></a> - zlib port to JavaScript, used to inflate DEFLATE-compressed AuthnRequest redirect payloads.</li>
</ul>
<p class="su-dialog-fineprint">All trademarks are property of their respective owners.</p>
</div>
</dialog>
<form id="realPostForm" method="POST">
<input type="hidden" name="SAMLResponse" id="hiddenSAMLResponse">
</form>
<script>
(() => {
const skillLinkEl = document.getElementById('skillLink');
if (skillLinkEl) {
const p = location.pathname;
skillLinkEl.href = (p === '/' || p === '') ? '/llms.txt' : p.replace(/\/$/, '') + '.md';
}
const toggle = document.getElementById('themeToggle');
const root = document.documentElement;
const setThemeUI = (t) => {
root.setAttribute('data-theme', t);
try { localStorage.setItem('su-tool-theme', t); } catch {}
};
toggle.addEventListener('click', () => {
setThemeUI(root.getAttribute('data-theme') === 'dark' ? 'light' : 'dark');
});
try {
const saved = localStorage.getItem('su-tool-theme');
if (saved) setThemeUI(saved);
else if (window.matchMedia('(prefers-color-scheme: light)').matches) setThemeUI('light');
} catch {}
})();
(() => {
const dlg = document.getElementById('privacyDialog');
document.getElementById('privacyOpen').addEventListener('click', () => dlg.showModal());
document.getElementById('privacyClose').addEventListener('click', () => dlg.close());
})();
(() => {
const dlg = document.getElementById('creditsDialog');
document.getElementById('creditsOpen').addEventListener('click', () => dlg.showModal());
document.getElementById('creditsClose').addEventListener('click', () => dlg.close());
})();
// ==========================================
// 1. CONFIGURATION
// ==========================================
const PUBLIC_CERT = `-----BEGIN CERTIFICATE-----
MIIDYjCCAkqgAwIBAgIUZ2p8K7GMXGk6xwCS9S91BUl1JnAwDQYJKoZIhvcNAQEL
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
cmF0ZWQgQ0EwIBcNMjMwOTIzMTUyMDE0WhgPMjA3MzA5MTAxNTIwMTRaMBExDzAN
BgNVBAMTBmtpYmFuYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMOU
r52dbZ5dY0BoP2p7CEnOpG+qHTNrOAqZO/OJfniPMtpGmwAMl3WZDca6u2XkV2KE
qQyevQ2ADk6G3o8S2RU8mO/+UweuCDF7LHuSdxEGTpucidZErmVhEGUOFosL5UeB
AtIDWxvWwgK+W9Yzt5IEN2HzNCZ6h0dOSk2r9EjVMG5yF4Q6kuqOYxBT7jxoaOtO
OCrgBRummtUga4T13WZ/ZIyyHpXj2+JD4YEmrDyoTa7NLaphv0hnVhHXYoYBI/c6
2SwwAoBlmtDmlinwSACQ3o/8eLWk0tqkIP14rc3oFh3m7D2c3c2m2HXuyoSDMfGW
beG2IE1Q3idcGmeG3qsCAwEAAaOBjDCBiTAdBgNVHQ4EFgQUMOUM7w5jmIozDvnq
RpM779m5GigwHwYDVR0jBBgwFoAUMEwqwI5b0MYpNxwaHJ9Tw1Lp3p4wPAYDVR0R
BDUwM4IUaG9zdC5kb2NrZXIuaW50ZXJuYWyCCWxvY2FsaG9zdIIEZXMwM4IEZXMw
MoIEZXMwMTAJBgNVHRMEAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQCxqvQYXSKqgpdl
SP4gXgwipAnYsoW9qkgWQODTvSBEzUdOWme0d3j7i2l6Ur/nVSv5YjkqAv1hf/yJ
Hrk9h+j29ZO/aQ/KDh5i/gTEUnPw3Bxbw47dfn23tjMWO7NCU1fr5HNztRsa/gQr
e9s07g25u/gTfTi9Fyu0lcRe3bXOLS/mFVcuC5oxuS65R9OlbIsiORkZ2EfwuNUf
wAAYOGPIjM2VlQCvBitefsd/SzRKHdxSPy6KSjkO6MGEGo87fr7B7Nx1qp1DVrK7
q9XeP1Cuygjg9WTcnsvWvNw8CssyuFM6X/3tGjpPasXwLvNUoG2AairK2AYTWhvS
foE31cFg
-----END CERTIFICATE-----`;
const PRIVATE_KEY = `-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAw5SvnZ1tnl1jQGg/ansISc6kb6odM2s4Cpk784l+eI8y2kab
AAyXdZkNxrq7ZeRXYoSpDJ69DYAOTobejxLZFTyY7/5TB64IMXsse5J3EQZOm5yJ
1kSuZWEQZQ4WiwvlR4EC0gNbG9bCAr5b1jO3kgQ3YfM0JnqHR05KTav0SNUwbnIX
hDqS6o5jEFPuPGho6044KuAFG6aa1SBrhPXdZn9kjLIelePb4kPhgSasPKhNrs0t
qmG/SGdWEddihgEj9zrZLDACgGWa0OaWKfBIAJDej/x4taTS2qQg/XitzegWHebs
PZzdzabYde7KhIMx8ZZt4bYgTVDeJ1waZ4beqwIDAQABAoIBABaXTBm2n3zVaKt9
3yVbhL+RwOitC6Zu0hBXVtdwoE0orUUNNsYwriYFQdQcqZzBXV6h2Cz/APNYQU7M
wVRhZvXPBBNkmw6eCZA9nAvCBULQKbBLypgXYtWO+qfRksUI4Lj7q+m6PYHfspVC
i7UYUDHrjsIfp3xyVsHjxy1lmVf4JFAANNHAQeYPR6l5bw/t5yA6qQ9vBtVRz9da
nCE2mQHAODXHMXdiIss4YA3a3uIuN54ud0/cWP/Pn2eM2MHsQYEKFISd7rZ81wlE
+9DmENkL3L9iK0Zx4xUTGGS8R8oM5jimUaa4PQLwoD6IolY0C33Ri6d4IK23AtOH
/+687lECgYEA0oJ2CPNCmbB4Sy7ry3PYZhxZk8qaS5dmYrmB+Z5wNu/mpC2/6M72
Vkol3BG+5yPgAB4SW09TeRh7VczGu+8juZW1q/Hi1MinhwCfGOvWlIFD9+G4d/gF
5EgWaDwCkimUo218Wry88hCzWuUKyd4HS3PODE0v39Jt1eLSQFGbqEcCgYEA7dha
UBs/I0kPvrYmlDrEH0dJRyvaG5ODv2gqvPtURNqFNMWAZ7146ZTDe2IvZ5bRTikc
B+lwlkMb+yhPvoGX1o3EkOYUhdUcgzSU9nL+ynSoWeOqprJ9Q/al4rIEh8ebvbZI
RF0qvBU6Q8Qg6aA/pcTVHU0+fFe6GDYarWvarH0CgYEAoxYphfOYVGMwPucCDKQa
Mbmi+GnNMeUAkFmxxYam3xjq8aTz+dRlaiKVxDIHWSElCFJD3HPPcpCx9J3qFW1G
mx/OGIEUP8+YYnHr0C3eFz0yQBeih2cigWIL4gMj5sLKAfbvkYiJRWwE19V8jzox
IpZ8OnGONnPbXgoU43mWAz8CgYEA3qvrAYxAtBw2rWmC/Mt3yYDHzeX0MFUOxygS
uxLhdgTPKPSunnD4vlYUHXNyxhygn/hE0fNvAH6bt6up3MUfDjNzj+SX2iQGqZ+U
xpYqjAhjhKRso9v/Ap3r+CyJqUTrPdVmGvrOg3+sKL15wr/QVrXMf75NfcPz6a7d
kvaip1ECgYA/T6EllMlRBM7hMnhZlgt3Ccu/e6VcVzQxqp0EewHzw+N17LdoaWaB
0bw9AqTwLeEhf4s4vidB7pO8YGNkCOKkQ3gqA/pF21VtF4xBRP6iYFa9rEGrHsRU
as68JJ6Lk+gn0aJ0RJNRaOa8xeoA/YWYNfnCfiAHj82UzP5TT4L/BQ==
-----END RSA PRIVATE KEY-----`;
const ISSUER = "urn:mock-idp";
const SAML_CALLBACK_PATH = "/api/security/saml/callback";
(() => {
// ==========================================
// 2. UI STATE
// ==========================================
let currentMode = 'simple';
let selectedRoles = ['viewer'];
let samlRequestId = null;
let samlRequestAcsUrl = null;
const $ = (id) => document.getElementById(id);
// ==========================================
// 3. MODE SWITCHING
// ==========================================
const setMode = (mode) => {
currentMode = mode;
const isAdvanced = mode === 'advanced';
$('simpleModeBtn').className = isAdvanced ? 'tab' : 'tab active';
$('advancedModeBtn').className = isAdvanced ? 'tab active' : 'tab';
$('destinationSection').classList.toggle('hidden', !isAdvanced);
$('statusSection').classList.toggle('hidden', !isAdvanced);
};
// ==========================================
// 4. ROLE MANAGEMENT
// ==========================================
const REMOVE_ROLE_ICON = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>';
const renderRoles = () => {
const container = $('selectedRoles');
container.replaceChildren();
for (const role of selectedRoles) {
const tag = document.createElement('span');
tag.className = 'role-tag';
tag.append(role, ' ');
const removeBtn = document.createElement('button');
removeBtn.type = 'button';
removeBtn.title = 'Remove role';
removeBtn.innerHTML = REMOVE_ROLE_ICON;
removeBtn.addEventListener('click', () => removeRole(role));
tag.appendChild(removeBtn);
container.appendChild(tag);
}
};
const escapeHtml = (text) => {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
};
const handleRoleSelect = () => {
const select = $('roleSelect');
const { value } = select;
if (value === '__custom__') {
$('customRoleInput').classList.remove('hidden');
$('customRoleName').focus();
} else if (value && !selectedRoles.includes(value)) {
selectedRoles.push(value);
renderRoles();
}
select.value = '';
};
const addCustomRole = () => {
const input = $('customRoleName');
const roleName = input.value.trim();
if (roleName && !selectedRoles.includes(roleName)) {
selectedRoles.push(roleName);
renderRoles();
}
input.value = '';
hideCustomRoleInput();
};
const hideCustomRoleInput = () => {
$('customRoleInput').classList.add('hidden');
$('customRoleName').value = '';
};
const removeRole = (role) => {
selectedRoles = selectedRoles.filter((r) => r !== role);
renderRoles();
};
// ==========================================
// 5. DESTINATION URL HANDLING
// ==========================================
const normalizeDestination = (input) => {
try {
let urlStr = input.trim();
if (!urlStr.startsWith('http://') && !urlStr.startsWith('https://')) {
urlStr = `http://${urlStr}`;
}
return new URL(urlStr).origin + SAML_CALLBACK_PATH;
} catch {
return input.replace(/\/+$/, '') + SAML_CALLBACK_PATH;
}
};
// ==========================================
// 6. EXCLUSIVE XML CANONICALIZATION (exc-c14n)
// ==========================================
const exclusiveC14n = (xmlString, inclusiveNamespaces = []) => {
const doc = new DOMParser().parseFromString(xmlString, 'application/xml');
if (doc.documentElement.nodeName === 'parsererror') {
throw new Error(`XML parsing error: ${doc.documentElement.textContent}`);
}
return canonicalizeNode(doc.documentElement, {}, inclusiveNamespaces);
};
const canonicalizeNode = (node, renderedNs, inclusiveNsPrefixes) => {
if (node.nodeType === Node.TEXT_NODE) return escapeText(node.textContent);
if (node.nodeType !== Node.ELEMENT_NODE) return '';
const visiblyUtilized = new Set();
const localNsDecls = {};
const elemPrefix = node.prefix || '';
const elemNs = node.namespaceURI || '';
if (elemNs) visiblyUtilized.add(elemPrefix);
const regularAttrs = [];
for (const attr of node.attributes) {
if (attr.name === 'xmlns') {
localNsDecls[''] = attr.value;
} else if (attr.name.startsWith('xmlns:')) {
localNsDecls[attr.name.substring(6)] = attr.value;
} else {
regularAttrs.push(attr);
if (attr.prefix) visiblyUtilized.add(attr.prefix);
}
}
for (const prefix of inclusiveNsPrefixes) visiblyUtilized.add(prefix);
const nsToRender = [];
for (const prefix of visiblyUtilized) {
let nsUri;
if (prefix in localNsDecls) nsUri = localNsDecls[prefix];
else if (prefix === elemPrefix && elemNs) nsUri = elemNs;
else nsUri = node.lookupNamespaceURI(prefix) ?? '';
if (renderedNs[prefix] !== nsUri) nsToRender.push({ prefix, uri: nsUri });
}
nsToRender.sort((a, b) => {
if (a.prefix === '') return -1;
if (b.prefix === '') return 1;
return a.prefix.localeCompare(b.prefix);
});
regularAttrs.sort((a, b) => {
const aHasNs = !!a.namespaceURI;
const bHasNs = !!b.namespaceURI;
if (!aHasNs && !bHasNs) return a.localName.localeCompare(b.localName);
if (!aHasNs) return -1;
if (!bHasNs) return 1;
if (a.namespaceURI !== b.namespaceURI) return a.namespaceURI.localeCompare(b.namespaceURI);
return a.localName.localeCompare(b.localName);
});
const tagName = elemPrefix ? `${elemPrefix}:${node.localName}` : node.localName;
const parts = [`<${tagName}`];
for (const { prefix, uri } of nsToRender) {
parts.push(prefix === '' ? ` xmlns="${escapeAttr(uri)}"` : ` xmlns:${prefix}="${escapeAttr(uri)}"`);
}
for (const a of regularAttrs) parts.push(` ${a.name}="${escapeAttr(a.value)}"`);
parts.push('>');
const childRenderedNs = { ...renderedNs };
for (const { prefix, uri } of nsToRender) childRenderedNs[prefix] = uri;
for (const child of node.childNodes) parts.push(canonicalizeNode(child, childRenderedNs, inclusiveNsPrefixes));
parts.push(`</${tagName}>`);
return parts.join('');
};
const escapeText = (text) => text
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\r/g, '
');
const escapeAttr = (text) => text
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/"/g, '"')
.replace(/\t/g, '	')
.replace(/\n/g, '
')
.replace(/\r/g, '
');
// ==========================================
// 7. HELPER FUNCTIONS
// ==========================================
const log = (msg, type = 'info') => {
if (currentMode !== 'advanced') return;
const box = $('statusBox');
const cls = type === 'error' ? 'text-error' : type === 'success' ? 'text-success' : 'text-info';
box.insertAdjacentHTML('beforeend', `<div class="${cls}">> ${msg}</div>`);
box.scrollTop = box.scrollHeight;
};
const generateID = () => `_${Array.from(crypto.getRandomValues(new Uint8Array(20)), (b) => b.toString(16).padStart(2, '0')).join('')}`;
const sha256Base64 = (str) => {
const md = new KJUR.crypto.MessageDigest({ alg: 'sha256' });
md.updateString(str);
return hextob64(md.digest());
};
// ==========================================
// 8. SAML REQUEST PARSING (SP-INITIATED FLOW)
// ==========================================
const parseSAMLRequestFromUrl = () => {
const samlRequest = new URLSearchParams(window.location.search).get('SAMLRequest');
if (!samlRequest) return null;
try {
log('Parsing SAMLRequest from URL...');
const bytes = Uint8Array.from(atob(samlRequest), (c) => c.charCodeAt(0));
const inflated = pako.inflateRaw(bytes);
const xmlString = new TextDecoder('utf-8').decode(inflated);
log(' SAMLRequest decoded successfully');
const doc = new DOMParser().parseFromString(xmlString, 'application/xml');
if (doc.documentElement.nodeName === 'parsererror') throw new Error('Failed to parse SAMLRequest XML');
const rootEl = doc.documentElement;
const id = rootEl.getAttribute('ID');
if (!id) throw new Error('No ID attribute found in SAMLRequest');
const acsUrl = rootEl.getAttribute('AssertionConsumerServiceURL') || '';
log(` Extracted Request ID: ${id}`, 'success');
if (acsUrl) log(` Extracted ACS URL: ${acsUrl}`, 'success');
return { id, acsUrl };
} catch (err) {
log(`Failed to parse SAMLRequest: ${err.message}`, 'error');
return null;
}
};
// ==========================================
// 9. MAIN LOGIC
// ==========================================
const handleProcess = (e) => {
e.preventDefault();
if (currentMode === 'advanced') $('statusBox').innerHTML = 'Initializing...<br>';
const username = $('username').value;
const fullname = $('fullname').value;
const email = $('email').value;
const roles = selectedRoles.length > 0 ? selectedRoles : ['viewer'];
const rawDestination = $('destination').value || 'http://localhost:5601';
const destination = normalizeDestination(rawDestination);
$('realPostForm').action = destination;
const now = new Date();
const issueInstant = now.toISOString();
const notOnOrAfter = new Date(now.getTime() + 60 * 60 * 1000).toISOString();
const assertionID = generateID();
const responseID = generateID();
const sessionIndex = Math.floor(Math.random() * 10000000000000000).toString();
const nameID = generateID();
try {
log('1. Building SAML Assertion...');
if (samlRequestId) log(` SP-Initiated flow: InResponseTo="${samlRequestId}"`);
else log(' IdP-Initiated flow: No InResponseTo attribute');
const roleAttributeValues = roles.map((role) => `<saml:AttributeValue>${role}</saml:AttributeValue>`).join('');
const inResponseToAttr = samlRequestId ? ` InResponseTo="${samlRequestId}"` : '';
const assertionXml =
`<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" ID="${assertionID}" IssueInstant="${issueInstant}">` +
`<saml:Issuer>${ISSUER}</saml:Issuer>` +
'<saml:Subject>' +
`<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:transient">${nameID}</saml:NameID>` +
'<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">' +
`<saml:SubjectConfirmationData NotOnOrAfter="${notOnOrAfter}" Recipient="${destination}"${inResponseToAttr}/>` +
'</saml:SubjectConfirmation>' +
'</saml:Subject>' +
`<saml:AuthnStatement AuthnInstant="${issueInstant}" SessionIndex="${sessionIndex}">` +
'<saml:AuthnContext>' +
'<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>' +
'</saml:AuthnContext>' +
'</saml:AuthnStatement>' +
'<saml:AttributeStatement>' +
'<saml:Attribute FriendlyName="principal" Name="http://saml.elastic-cloud.com/attributes/principal" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">' +
`<saml:AttributeValue>${username}</saml:AttributeValue>` +
'</saml:Attribute>' +
'<saml:Attribute FriendlyName="roles" Name="http://saml.elastic-cloud.com/attributes/roles" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">' +
roleAttributeValues +
'</saml:Attribute>' +
'<saml:Attribute FriendlyName="email" Name="http://saml.elastic-cloud.com/attributes/email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">' +
`<saml:AttributeValue>${email}</saml:AttributeValue>` +
'</saml:Attribute>' +
'<saml:Attribute FriendlyName="name" Name="http://saml.elastic-cloud.com/attributes/name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">' +
`<saml:AttributeValue>${fullname}</saml:AttributeValue>` +
'</saml:Attribute>' +
'</saml:AttributeStatement>' +
'</saml:Assertion>';
log('2. Canonicalizing Assertion (exc-c14n)...');
const canonicalizedAssertion = exclusiveC14n(assertionXml);
log('3. Computing SHA-256 digest...');
const digestBase64 = sha256Base64(canonicalizedAssertion);
log(` Digest: ${digestBase64.substring(0, 20)}...`);
log('4. Building SignedInfo...');
const signedInfoXml =
'<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">' +
'<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>' +
'<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>' +
`<Reference URI="#${assertionID}">` +
'<Transforms>' +
'<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>' +
'<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>' +
'</Transforms>' +
'<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>' +
`<DigestValue>${digestBase64}</DigestValue>` +
'</Reference>' +
'</SignedInfo>';
log('5. Canonicalizing SignedInfo...');
const canonicalizedSignedInfo = exclusiveC14n(signedInfoXml);
log('6. Signing with RSA-SHA256...');
const rsaKey = KEYUTIL.getKey(PRIVATE_KEY);
const sig = new KJUR.crypto.Signature({ alg: 'SHA256withRSA' });
sig.init(rsaKey);
sig.updateString(canonicalizedSignedInfo);
const signatureHex = sig.sign();
const signatureBase64 = hextob64(signatureHex);
log(` Signature: ${signatureBase64.substring(0, 20)}...`);
log('7. Verifying signature...');
const verifySig = new KJUR.crypto.Signature({ alg: 'SHA256withRSA' });
verifySig.init(KEYUTIL.getKey(PUBLIC_CERT));
verifySig.updateString(canonicalizedSignedInfo);
if (!verifySig.verify(signatureHex)) {
log(' Signature verification FAILED!', 'error');
return;
}
log(' Signature verified successfully!', 'success');
log('8. Assembling signed assertion...');
const signatureBlock =
'<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">' +
'<SignedInfo>' +
'<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>' +
'<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>' +
`<Reference URI="#${assertionID}">` +
'<Transforms>' +
'<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>' +
'<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>' +
'</Transforms>' +
'<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>' +
`<DigestValue>${digestBase64}</DigestValue>` +
'</Reference>' +
'</SignedInfo>' +
`<SignatureValue>${signatureBase64}</SignatureValue>` +
'</Signature>';
const signedAssertionXml = assertionXml.replace(
`<saml:Issuer>${ISSUER}</saml:Issuer>`,
`<saml:Issuer>${ISSUER}</saml:Issuer>${signatureBlock}`,
);
log('9. Building SAML Response...');
const responseXml =
`<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="${responseID}"${inResponseToAttr} Version="2.0" IssueInstant="${issueInstant}" Destination="${destination}">` +
`<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">${ISSUER}</saml:Issuer>` +
'<samlp:Status>' +
'<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>' +
'</samlp:Status>' +
signedAssertionXml +
'</samlp:Response>';
log('10. Encoding and submitting...');
const base64Response = btoa(unescape(encodeURIComponent(responseXml)));
log(`Submitting to: ${destination}`, 'success');
$('hiddenSAMLResponse').value = base64Response;
$('realPostForm').submit();
} catch (err) {
log(`ERROR: ${err.message}`, 'error');
console.error(err);
}
};
// ==========================================
// 10. BANNER
// ==========================================
const updateSAMLRequestUI = () => {
const form = $('samlForm');
const banner = document.createElement('div');
banner.id = 'spInitiatedBanner';
banner.className = 'info-banner';
const destMsg = samlRequestAcsUrl
? ' Destination auto-filled from <code>AssertionConsumerServiceURL</code>.'
: '';
banner.innerHTML =
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>' +
`<span><strong>SP-Initiated Flow:</strong> Request ID <code>${escapeHtml(samlRequestId)}</code> will be included in response.${destMsg}</span>`;
form.insertBefore(banner, form.firstChild);
};
// ==========================================
// 11. INITIALIZATION
// ==========================================
document.addEventListener('DOMContentLoaded', () => {
$('simpleModeBtn').addEventListener('click', () => setMode('simple'));
$('advancedModeBtn').addEventListener('click', () => setMode('advanced'));
$('samlForm').addEventListener('submit', handleProcess);
$('roleSelect').addEventListener('change', handleRoleSelect);
$('addCustomRoleBtn').addEventListener('click', addCustomRole);
$('cancelCustomRoleBtn').addEventListener('click', hideCustomRoleInput);
$('customRoleName').addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
e.preventDefault();
addCustomRole();
}
});
renderRoles();
const parsed = parseSAMLRequestFromUrl();
if (!parsed) return;
samlRequestId = parsed.id;
samlRequestAcsUrl = parsed.acsUrl || null;
if (samlRequestAcsUrl) {
const destinationInput = $('destination');
try {
destinationInput.value = new URL(samlRequestAcsUrl).origin;
} catch {
destinationInput.value = samlRequestAcsUrl;
}
setMode('advanced');
}
updateSAMLRequestUI();
});
})();
</script>
</body>
</html>