mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
1 parent
040d659055
commit
652ac8234d
4 files changed
+377
-2
No files matched your search
@@ -42,6 +42,7 @@
|
||||
"precommit": "pnpm install --ignore-scripts && pnpm lint --fix && pnpm typecheck"
|
||||
},
|
||||
"dependencies": {
|
||||
"@boxyhq/saml20": "^1.16.0",
|
||||
"@chenfengyuan/vue-barcode": "^2.0.2",
|
||||
"@date-fns/utc": "^2.1.1",
|
||||
"@dice-roller/rpg-dice-roller": "^5.5.1",
|
||||
@@ -284,6 +285,7 @@
|
||||
"openpgp": "^6.3.0",
|
||||
"otpauth-migration": "^1.0.0",
|
||||
"oui-data": "^1.1.571",
|
||||
"pako": "^3.0.0",
|
||||
"parse-duration": "^2.1.6",
|
||||
"parse-torrent": "^11.0.19",
|
||||
"paseto-ts": "^2.0.5",
|
||||
|
||||
Generated
+80
-2
@@ -23,6 +23,9 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@boxyhq/saml20':
|
||||
specifier: ^1.16.0
|
||||
version: 1.16.0
|
||||
'@chenfengyuan/vue-barcode':
|
||||
specifier: ^2.0.2
|
||||
version: 2.0.2(jsbarcode@3.12.1)(vue@3.3.4)
|
||||
@@ -749,6 +752,9 @@ importers:
|
||||
oui-data:
|
||||
specifier: ^1.1.571
|
||||
version: 1.1.571
|
||||
pako:
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0
|
||||
parse-duration:
|
||||
specifier: ^2.1.6
|
||||
version: 2.1.6
|
||||
@@ -2161,6 +2167,9 @@ packages:
|
||||
'@borewit/text-codec@0.2.1':
|
||||
resolution: {integrity: sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw==}
|
||||
|
||||
'@boxyhq/saml20@1.16.0':
|
||||
resolution: {integrity: sha512-uSdGrZTv8O9bhcYDg6iwUXVGbBlbL1jTatdwhTowZu6jUInIwrq7txIvuDxH3j/iFD8d70xVc6zSAxP4T9XeOw==}
|
||||
|
||||
'@braintree/sanitize-url@7.1.1':
|
||||
resolution: {integrity: sha512-i1L7noDNxtFyL5DmZafWy1wRVhGehQmzZaz1HiN5e7iylJMSZR7ekOV7NsIqa5qBldlLrsKv4HbgFUVlQrz8Mw==}
|
||||
|
||||
@@ -4999,6 +5008,10 @@ packages:
|
||||
'@webassemblyjs/wast-printer@1.14.1':
|
||||
resolution: {integrity: sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==}
|
||||
|
||||
'@xmldom/is-dom-node@1.0.1':
|
||||
resolution: {integrity: sha512-CJDxIgE5I0FH+ttq/Fxy6nRpxP70+e2O048EPe85J2use3XKdatVM7dDVvFNjQudd9B49NPoZ+8PG49zj4Er8Q==}
|
||||
engines: {node: '>= 16'}
|
||||
|
||||
'@xmldom/xmldom@0.7.13':
|
||||
resolution: {integrity: sha512-lm2GW5PkosIzccsaZIz7tp8cPADSIlIHWDFTR1N0SzfinhhYgeIQjFMz4rYzanCScr3DqQLeomUDArp6MWKm+g==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@@ -6752,6 +6765,9 @@ packages:
|
||||
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
escape-html@1.0.3:
|
||||
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
||||
|
||||
escape-latex@1.2.0:
|
||||
resolution: {integrity: sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==}
|
||||
|
||||
@@ -9363,6 +9379,9 @@ packages:
|
||||
pako@1.0.11:
|
||||
resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
|
||||
|
||||
pako@3.0.0:
|
||||
resolution: {integrity: sha512-TGPtlCI1pSUSbkOIxOUUHNrBa0muz4mAp32cYUF3RoSa5c73jiQTKOKo22gaa4DxLggQrda/DAdax5QkcHPvYA==}
|
||||
|
||||
param-case@2.1.1:
|
||||
resolution: {integrity: sha512-eQE845L6ot89sk2N8liD8HAuH4ca6Vvr7VWAWwt7+kvvG5aBcPmmphQ68JsEG2qa9n1TykS2DLeMt363AAH8/w==}
|
||||
|
||||
@@ -11864,6 +11883,13 @@ packages:
|
||||
engines: {node: '>=0.8'}
|
||||
hasBin: true
|
||||
|
||||
xml-crypto@6.1.2:
|
||||
resolution: {integrity: sha512-leBOVQdVi8FvPJrMYoum7Ici9qyxfE4kVi+AkpUoYCSXaQF4IlBm1cneTK9oAxR61LpYxTx7lNcsnBIeRpGW2w==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
xml-encryption@4.0.1:
|
||||
resolution: {integrity: sha512-ENtwvonaBs59ssASLh4HpfBAYfBBvl9+HudkfE71z9pTiNmXtyuyr50qmCW7o8/3xVh/aNosYYRjdZdm+fO09g==}
|
||||
|
||||
xml-formatter@3.6.7:
|
||||
resolution: {integrity: sha512-IsfFYJQuoDqtUlKhm4EzeoBOb+fQwzQVeyxxAQ0sThn/nFnQmyLPTplqq4yRhaOENH/tAyujD2TBfIYzUKB6hg==}
|
||||
engines: {node: '>= 16'}
|
||||
@@ -11887,6 +11913,10 @@ packages:
|
||||
resolution: {integrity: sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
xml2js@0.6.2:
|
||||
resolution: {integrity: sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
xml@1.0.1:
|
||||
resolution: {integrity: sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==}
|
||||
|
||||
@@ -11894,6 +11924,10 @@ packages:
|
||||
resolution: {integrity: sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==}
|
||||
engines: {node: '>=4.0'}
|
||||
|
||||
xmlbuilder@15.1.1:
|
||||
resolution: {integrity: sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==}
|
||||
engines: {node: '>=8.0'}
|
||||
|
||||
xmlchars@2.2.0:
|
||||
resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
|
||||
|
||||
@@ -11901,6 +11935,14 @@ packages:
|
||||
resolution: {integrity: sha512-jOSBw4iYbm9inNP0DbQB7cO0tPBfogG3oLA739eTO3WgJXAelLyZcFlCe2W/gBaYXT0pglXN6tJ7svFVaewBmA==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
xpath@0.0.32:
|
||||
resolution: {integrity: sha512-rxMJhSIoiO8vXcWvSifKqhvV96GjiD5wYb8/QHdoRyQvraTpp4IEv944nhGausZZ3u7dhQXteZuZbaqfpB7uYw==}
|
||||
engines: {node: '>=0.6.0'}
|
||||
|
||||
xpath@0.0.33:
|
||||
resolution: {integrity: sha512-NNXnzrkDrAzalLhIUc01jO2mOzXGXh1JwPgkihcLLzw98c0WgYDmmjSh1Kl3wzaxSVWMuA+fe0WTWOBDWCBmNA==}
|
||||
engines: {node: '>=0.6.0'}
|
||||
|
||||
xpath@0.0.34:
|
||||
resolution: {integrity: sha512-FxF6+rkr1rNSQrhUNYrAFJpRXNzlDoMxeXN5qI84939ylEv3qqPFKa85Oxr6tDaJKqwW6KKyo2v26TSv3k6LeA==}
|
||||
engines: {node: '>=0.6.0'}
|
||||
@@ -13267,6 +13309,14 @@ snapshots:
|
||||
|
||||
'@borewit/text-codec@0.2.1': {}
|
||||
|
||||
'@boxyhq/saml20@1.16.0':
|
||||
dependencies:
|
||||
'@xmldom/xmldom': 0.9.10
|
||||
xml-crypto: 6.1.2
|
||||
xml-encryption: 4.0.1
|
||||
xml2js: 0.6.2
|
||||
xmlbuilder: 15.1.1
|
||||
|
||||
'@braintree/sanitize-url@7.1.1': {}
|
||||
|
||||
'@cfcs/core@0.0.6':
|
||||
@@ -16558,12 +16608,13 @@ snapshots:
|
||||
'@webassemblyjs/ast': 1.14.1
|
||||
'@xtuc/long': 4.2.2
|
||||
|
||||
'@xmldom/is-dom-node@1.0.1': {}
|
||||
|
||||
'@xmldom/xmldom@0.7.13': {}
|
||||
|
||||
'@xmldom/xmldom@0.8.13': {}
|
||||
|
||||
'@xmldom/xmldom@0.9.10':
|
||||
optional: true
|
||||
'@xmldom/xmldom@0.9.10': {}
|
||||
|
||||
'@xterm/xterm@5.5.0': {}
|
||||
|
||||
@@ -18485,6 +18536,8 @@ snapshots:
|
||||
|
||||
escalade@3.2.0: {}
|
||||
|
||||
escape-html@1.0.3: {}
|
||||
|
||||
escape-latex@1.2.0: {}
|
||||
|
||||
escape-quotes@1.0.2:
|
||||
@@ -21331,6 +21384,8 @@ snapshots:
|
||||
|
||||
pako@1.0.11: {}
|
||||
|
||||
pako@3.0.0: {}
|
||||
|
||||
param-case@2.1.1:
|
||||
dependencies:
|
||||
no-case: 2.3.2
|
||||
@@ -24267,6 +24322,18 @@ snapshots:
|
||||
|
||||
xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz: {}
|
||||
|
||||
xml-crypto@6.1.2:
|
||||
dependencies:
|
||||
'@xmldom/is-dom-node': 1.0.1
|
||||
'@xmldom/xmldom': 0.8.13
|
||||
xpath: 0.0.33
|
||||
|
||||
xml-encryption@4.0.1:
|
||||
dependencies:
|
||||
'@xmldom/xmldom': 0.8.13
|
||||
escape-html: 1.0.3
|
||||
xpath: 0.0.32
|
||||
|
||||
xml-formatter@3.6.7:
|
||||
dependencies:
|
||||
xml-parser-xo: 4.1.5
|
||||
@@ -24286,14 +24353,25 @@ snapshots:
|
||||
sax: 1.2.4
|
||||
xmlbuilder: 11.0.1
|
||||
|
||||
xml2js@0.6.2:
|
||||
dependencies:
|
||||
sax: 1.6.0
|
||||
xmlbuilder: 11.0.1
|
||||
|
||||
xml@1.0.1: {}
|
||||
|
||||
xmlbuilder@11.0.1: {}
|
||||
|
||||
xmlbuilder@15.1.1: {}
|
||||
|
||||
xmlchars@2.2.0: {}
|
||||
|
||||
xpath-to-css@1.2.0: {}
|
||||
|
||||
xpath@0.0.32: {}
|
||||
|
||||
xpath@0.0.33: {}
|
||||
|
||||
xpath@0.0.34: {}
|
||||
|
||||
xslt-processor@3.4.0:
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Key } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'SAML Parser',
|
||||
path: '/saml-parser',
|
||||
description: 'Detects SAML input (Base64, DEFLATE, or XML), parses, validates its signature, and displays a structured view of the assertion—including issuer, subject, conditions, authentication context, claims, and validation status.',
|
||||
keywords: ['saml', 'assertion', 'decoder', 'parser'],
|
||||
component: () => import('./saml-parser.vue'),
|
||||
icon: Key,
|
||||
createdAt: new Date('2026-07-04'),
|
||||
category: 'Crypto',
|
||||
});
|
||||
@@ -0,0 +1,282 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import saml from '@boxyhq/saml20';
|
||||
import { inflate } from 'pako';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const input = ref('');
|
||||
const thumbprint = ref('');
|
||||
const publicKey = ref('');
|
||||
const audience = ref('');
|
||||
const bypassExpiration = ref(false);
|
||||
|
||||
const parsingResult = ref<{
|
||||
type: 'assertion'
|
||||
raw: string
|
||||
profile: {
|
||||
claims?: any[]
|
||||
audience?: string
|
||||
issuer?: string
|
||||
assertionId?: string
|
||||
sessionIndex?: string
|
||||
notBefore?: string
|
||||
notOnOrAfter?: string
|
||||
}
|
||||
validation: { ok: boolean; error?: string | null }
|
||||
} | null>();
|
||||
|
||||
const error = ref<string | null>(null);
|
||||
const loading = ref(false);
|
||||
|
||||
function isBase64(str: string) {
|
||||
try {
|
||||
Base64.decode(str.trim());
|
||||
return true;
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function inflateBase64(str: string) {
|
||||
const bytes = Base64.toUint8Array(str.trim());
|
||||
return new TextDecoder().decode(inflate(bytes, { raw: true }));
|
||||
}
|
||||
|
||||
function looksLikeXml(str: string) {
|
||||
return str.trim().startsWith('<');
|
||||
}
|
||||
|
||||
async function validate(rawAssertion: string) {
|
||||
const options: any = {
|
||||
audience: audience.value || undefined,
|
||||
bypassExpiration: bypassExpiration.value || undefined,
|
||||
};
|
||||
if (thumbprint.value) {
|
||||
options.thumbprint = thumbprint.value;
|
||||
}
|
||||
if (publicKey.value) {
|
||||
options.publicKey = publicKey.value;
|
||||
}
|
||||
|
||||
try {
|
||||
const profile = await saml.validate(rawAssertion, options);
|
||||
return { ok: true, profile, error: null };
|
||||
}
|
||||
catch (e: any) {
|
||||
return { ok: false, profile: e.profile ?? null, error: String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
async function detect() {
|
||||
error.value = null;
|
||||
loading.value = true;
|
||||
parsingResult.value = null;
|
||||
|
||||
try {
|
||||
const raw = input.value.trim();
|
||||
if (!raw) {
|
||||
error.value = 'Input is empty.';
|
||||
return;
|
||||
}
|
||||
|
||||
let xml = raw;
|
||||
|
||||
if (isBase64(raw)) {
|
||||
xml = Base64.decode(raw);
|
||||
if (!looksLikeXml(xml)) {
|
||||
try {
|
||||
xml = inflateBase64(raw);
|
||||
}
|
||||
catch {
|
||||
error.value = 'Input is not valid Base64 or DEFLATE or XML.';
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error.value = 'Input is not valid Base64 or DEFLATE or XML.';
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedProfile = await saml.parse(xml);
|
||||
const validationResult = await validate(xml);
|
||||
|
||||
parsingResult.value = {
|
||||
type: 'assertion',
|
||||
raw: xml,
|
||||
profile: validationResult.profile ?? parsedProfile,
|
||||
validation: { ok: validationResult.ok, error: validationResult.error ?? null },
|
||||
};
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = 'Failed to parse SAML assertion.';
|
||||
}
|
||||
finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const profile = computed(() => parsingResult.value?.profile);
|
||||
const claims = computed(() => Object.entries(profile.value?.claims || []).map(([name, value]) => ({ name, value })));
|
||||
const validation = computed(() => parsingResult.value?.validation || { ok: false, error: null });
|
||||
|
||||
const signatureStatus = computed(() => {
|
||||
if (validation.value.ok) {
|
||||
return 'Signature & assertion valid';
|
||||
}
|
||||
if (validation.value.error) {
|
||||
return `Validation failed: ${validation.value.error}`;
|
||||
}
|
||||
return 'Not validated (no key / thumbprint)';
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="input"
|
||||
label="SAML assertion (Base64, DEFLATE, or XML):"
|
||||
multiline
|
||||
rows="8"
|
||||
placeholder="Paste SAML assertion (Base64, DEFLATE, or XML)"
|
||||
mb-2
|
||||
/>
|
||||
|
||||
<n-card size="small" title="Validation Options" mb-2>
|
||||
<c-input-text
|
||||
v-model:value="thumbprint"
|
||||
label="Thumbprint:"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
placeholder="Thumbprint (optional)"
|
||||
mb-1
|
||||
/>
|
||||
<c-input-text
|
||||
v-model:value="publicKey"
|
||||
label="Public Key:"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
multiline
|
||||
rows="3"
|
||||
placeholder="Public key (optional)"
|
||||
mb-1
|
||||
/>
|
||||
<c-input-text
|
||||
v-model:value="audience"
|
||||
label="Audience:"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
placeholder="Audience (optional)"
|
||||
mb-1
|
||||
/>
|
||||
<n-space justify="center">
|
||||
<n-switch v-model:value="bypassExpiration">
|
||||
<template #checked>
|
||||
Bypass Expiration
|
||||
</template>
|
||||
<template #unchecked>
|
||||
Don't Bypass Expiration
|
||||
</template>
|
||||
</n-switch>
|
||||
</n-space>
|
||||
</n-card>
|
||||
|
||||
<n-space justify="center">
|
||||
<n-button type="primary" :loading="loading" @click="detect">
|
||||
Detect, Parse and Validate
|
||||
</n-button>
|
||||
</n-space>
|
||||
|
||||
<n-alert v-if="error" type="error" show-icon mb-2 mt-2>
|
||||
{{ error }}
|
||||
</n-alert>
|
||||
|
||||
<c-card v-if="!error && !loading && parsingResult?.raw" title="Parsed SAML Assertion" mt-2>
|
||||
<input-copyable
|
||||
label="Issuer:"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:value="profile?.issuer || ''"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
label="Assertion Id:"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:value="profile?.assertionId || ''"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
label="Session Index:"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:value="profile?.sessionIndex || ''"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
label="NotBefore:"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:value="profile?.notBefore || ''"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
label="NotOnOrAfter:"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:value="profile?.notOnOrAfter || ''"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
label="Audience:"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:value="profile?.audience || ''"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
label="Signature Validation Status:"
|
||||
label-position="left"
|
||||
:value="signatureStatus"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<c-alert v-if="!parsingResult.validation?.ok && parsingResult.validation?.error" type="error" show-icon>
|
||||
{{ parsingResult.validation.error }}
|
||||
</c-alert>
|
||||
|
||||
<c-card v-if="claims.length > 0" size="small" title="Claims" mb-1>
|
||||
<n-data-table
|
||||
:columns="[
|
||||
{ title: 'Claim', key: 'claim' },
|
||||
{ title: 'Value', key: 'value' },
|
||||
]"
|
||||
:data="claims.map((c) => ({ claim: c.name, value: c.value }))"
|
||||
size="small"
|
||||
striped
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<c-card title="Raw Assertion" mt-2>
|
||||
<textarea-copyable
|
||||
:value="JSON.stringify(parsingResult.profile, null, 2)"
|
||||
language="json"
|
||||
mb-2
|
||||
/>
|
||||
|
||||
<textarea-copyable
|
||||
:value="parsingResult?.raw"
|
||||
language="xml"
|
||||
word-wrap
|
||||
/>
|
||||
</c-card>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user