mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fixed webauthn two factor authentication
This commit is contained in:
parent
624696711d
commit
b7573a40d7
3 changed files with 55 additions and 42 deletions
|
@ -21,8 +21,13 @@
|
||||||
|
|
||||||
class WebauthnTFA {
|
class WebauthnTFA {
|
||||||
|
|
||||||
// Decodes a Base64Url string
|
_b64UrlSafeEncode = (str) => {
|
||||||
_base64UrlDecode = (input) => {
|
const b64 = btoa(str);
|
||||||
|
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodes a Base64Url string
|
||||||
|
_b64UrlSafeDecode = (input) => {
|
||||||
input = input
|
input = input
|
||||||
.replace(/-/g, '+')
|
.replace(/-/g, '+')
|
||||||
.replace(/_/g, '/');
|
.replace(/_/g, '/');
|
||||||
|
@ -39,13 +44,16 @@ class WebauthnTFA {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Converts an array of bytes into a Base64Url string
|
// Converts an array of bytes into a Base64Url string
|
||||||
_arrayToBase64String = (a) => btoa(String.fromCharCode(...a));
|
_arrayToBase64String = (a) => {
|
||||||
|
const str = String.fromCharCode(...a);
|
||||||
|
return this._b64UrlSafeEncode(str);
|
||||||
|
}
|
||||||
|
|
||||||
// Prepares the public key options object returned by the Webauthn Framework
|
// Prepares the public key options object returned by the Webauthn Framework
|
||||||
_preparePublicKeyOptions = publicKey => {
|
_preparePublicKeyOptions = publicKey => {
|
||||||
//Convert challenge from Base64Url string to Uint8Array
|
//Convert challenge from Base64Url string to Uint8Array
|
||||||
publicKey.challenge = Uint8Array.from(
|
publicKey.challenge = Uint8Array.from(
|
||||||
this._base64UrlDecode(publicKey.challenge),
|
this._b64UrlSafeDecode(publicKey.challenge),
|
||||||
c => c.charCodeAt(0)
|
c => c.charCodeAt(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -67,7 +75,7 @@ class WebauthnTFA {
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
id: Uint8Array.from(
|
id: Uint8Array.from(
|
||||||
this._base64UrlDecode(data.id),
|
this._b64UrlSafeDecode(data.id),
|
||||||
c => c.charCodeAt(0)
|
c => c.charCodeAt(0)
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -81,7 +89,7 @@ class WebauthnTFA {
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
id: Uint8Array.from(
|
id: Uint8Array.from(
|
||||||
this._base64UrlDecode(data.id),
|
this._b64UrlSafeDecode(data.id),
|
||||||
c => c.charCodeAt(0)
|
c => c.charCodeAt(0)
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
"florianv/swap": "^4.0",
|
"florianv/swap": "^4.0",
|
||||||
"florianv/swap-bundle": "dev-master",
|
"florianv/swap-bundle": "dev-master",
|
||||||
"gregwar/captcha-bundle": "^2.1.0",
|
"gregwar/captcha-bundle": "^2.1.0",
|
||||||
"jbtronics/2fa-webauthn": "dev-master",
|
"jbtronics/2fa-webauthn": "^v2.0.0",
|
||||||
"jfcherng/php-diff": "^6.14",
|
"jfcherng/php-diff": "^6.14",
|
||||||
"league/csv": "^9.8.0",
|
"league/csv": "^9.8.0",
|
||||||
"league/html-to-markdown": "^5.0.1",
|
"league/html-to-markdown": "^5.0.1",
|
||||||
|
@ -154,11 +154,5 @@
|
||||||
"allow-contrib": false,
|
"allow-contrib": false,
|
||||||
"require": "6.2.*"
|
"require": "6.2.*"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"repositories": [
|
|
||||||
{
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/jbtronics/2fa-webauthn.git"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
67
composer.lock
generated
67
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b0d4bf26f478ca8451e65e618de7bde7",
|
"content-hash": "fa0dafb8fc42546d15378323ee9b6fb0",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "beberlei/assert",
|
"name": "beberlei/assert",
|
||||||
|
@ -2454,31 +2454,39 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jbtronics/2fa-webauthn",
|
"name": "jbtronics/2fa-webauthn",
|
||||||
"version": "dev-master",
|
"version": "v2.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/jbtronics/2fa-webauthn.git",
|
"url": "https://github.com/jbtronics/2fa-webauthn.git",
|
||||||
"reference": "ef886b0654766a6adb1e027ed1b3b57a3cbb9c5a"
|
"reference": "807ae06ccbc73a17983ea80b5a2e4cc78c07f8ad"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/jbtronics/2fa-webauthn/zipball/807ae06ccbc73a17983ea80b5a2e4cc78c07f8ad",
|
||||||
|
"reference": "807ae06ccbc73a17983ea80b5a2e4cc78c07f8ad",
|
||||||
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"nyholm/psr7": "^1.5",
|
"nyholm/psr7": "^1.5",
|
||||||
"php": "^7.4.0|^8.0",
|
"php": "^8.1",
|
||||||
"scheb/2fa-bundle": "^5.0.0|^6.0.0",
|
"scheb/2fa-bundle": "^6.0.0",
|
||||||
"symfony/framework-bundle": "^5.0|^6.0",
|
"symfony/framework-bundle": "^6.0",
|
||||||
"symfony/psr-http-message-bridge": "^2.1",
|
"symfony/psr-http-message-bridge": "^2.1",
|
||||||
"web-auth/webauthn-lib": "^3.3|^4.0"
|
"symfony/uid": "^6.0",
|
||||||
|
"web-auth/webauthn-lib": "^4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.5"
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"roave/security-advisories": "dev-latest"
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Jbtronics\\TFAWebauthn\\": "src/"
|
"Jbtronics\\TFAWebauthn\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
"MIT"
|
"MIT"
|
||||||
],
|
],
|
||||||
|
@ -2497,7 +2505,11 @@
|
||||||
"two-factor-authentication",
|
"two-factor-authentication",
|
||||||
"webauthn"
|
"webauthn"
|
||||||
],
|
],
|
||||||
"time": "2023-05-27T18:21:46+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/jbtronics/2fa-webauthn/issues",
|
||||||
|
"source": "https://github.com/jbtronics/2fa-webauthn/tree/v2.0.0"
|
||||||
|
},
|
||||||
|
"time": "2023-06-11T11:09:45+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jfcherng/php-color-output",
|
"name": "jfcherng/php-color-output",
|
||||||
|
@ -5555,23 +5567,23 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "s9e/text-formatter",
|
"name": "s9e/text-formatter",
|
||||||
"version": "2.13.1",
|
"version": "2.14.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/s9e/TextFormatter.git",
|
"url": "https://github.com/s9e/TextFormatter.git",
|
||||||
"reference": "bbd9e34e9c30d5daeb780f115fe69cd81dd9c352"
|
"reference": "48a2f3a3fb18af8d78330204732a3369441c4060"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/s9e/TextFormatter/zipball/bbd9e34e9c30d5daeb780f115fe69cd81dd9c352",
|
"url": "https://api.github.com/repos/s9e/TextFormatter/zipball/48a2f3a3fb18af8d78330204732a3369441c4060",
|
||||||
"reference": "bbd9e34e9c30d5daeb780f115fe69cd81dd9c352",
|
"reference": "48a2f3a3fb18af8d78330204732a3369441c4060",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-filter": "*",
|
"ext-filter": "*",
|
||||||
"lib-pcre": ">=8.13",
|
"lib-pcre": ">=8.13",
|
||||||
"php": ">=7.4",
|
"php": "^8.0",
|
||||||
"s9e/regexp-builder": "^1.4",
|
"s9e/regexp-builder": "^1.4",
|
||||||
"s9e/sweetdom": "^2.0"
|
"s9e/sweetdom": "^2.0"
|
||||||
},
|
},
|
||||||
|
@ -5591,7 +5603,7 @@
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"version": "2.13.1"
|
"version": "2.14.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -5623,9 +5635,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/s9e/TextFormatter/issues",
|
"issues": "https://github.com/s9e/TextFormatter/issues",
|
||||||
"source": "https://github.com/s9e/TextFormatter/tree/2.13.1"
|
"source": "https://github.com/s9e/TextFormatter/tree/2.14.0"
|
||||||
},
|
},
|
||||||
"time": "2023-02-11T00:18:05+00:00"
|
"time": "2023-06-08T07:19:50+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sabberworm/php-css-parser",
|
"name": "sabberworm/php-css-parser",
|
||||||
|
@ -15582,16 +15594,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/maker-bundle",
|
"name": "symfony/maker-bundle",
|
||||||
"version": "v1.48.0",
|
"version": "v1.49.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/maker-bundle.git",
|
"url": "https://github.com/symfony/maker-bundle.git",
|
||||||
"reference": "2e428e8432e9879187672fe08f1cc335e2a31dd6"
|
"reference": "ce1d424f76bbb377f1956cc7641e8e2eafe81cde"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/maker-bundle/zipball/2e428e8432e9879187672fe08f1cc335e2a31dd6",
|
"url": "https://api.github.com/repos/symfony/maker-bundle/zipball/ce1d424f76bbb377f1956cc7641e8e2eafe81cde",
|
||||||
"reference": "2e428e8432e9879187672fe08f1cc335e2a31dd6",
|
"reference": "ce1d424f76bbb377f1956cc7641e8e2eafe81cde",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -15605,7 +15617,8 @@
|
||||||
"symfony/filesystem": "^5.4.7|^6.0",
|
"symfony/filesystem": "^5.4.7|^6.0",
|
||||||
"symfony/finder": "^5.4.3|^6.0",
|
"symfony/finder": "^5.4.3|^6.0",
|
||||||
"symfony/framework-bundle": "^5.4.7|^6.0",
|
"symfony/framework-bundle": "^5.4.7|^6.0",
|
||||||
"symfony/http-kernel": "^5.4.7|^6.0"
|
"symfony/http-kernel": "^5.4.7|^6.0",
|
||||||
|
"symfony/process": "^5.4.7|^6.0"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"doctrine/doctrine-bundle": "<2.4",
|
"doctrine/doctrine-bundle": "<2.4",
|
||||||
|
@ -15617,9 +15630,8 @@
|
||||||
"doctrine/doctrine-bundle": "^2.4",
|
"doctrine/doctrine-bundle": "^2.4",
|
||||||
"doctrine/orm": "^2.10.0",
|
"doctrine/orm": "^2.10.0",
|
||||||
"symfony/http-client": "^5.4.7|^6.0",
|
"symfony/http-client": "^5.4.7|^6.0",
|
||||||
"symfony/phpunit-bridge": "^5.4.7|^6.0",
|
"symfony/phpunit-bridge": "^5.4.17|^6.0",
|
||||||
"symfony/polyfill-php80": "^1.16.0",
|
"symfony/polyfill-php80": "^1.16.0",
|
||||||
"symfony/process": "^5.4.7|^6.0",
|
|
||||||
"symfony/security-core": "^5.4.7|^6.0",
|
"symfony/security-core": "^5.4.7|^6.0",
|
||||||
"symfony/yaml": "^5.4.3|^6.0",
|
"symfony/yaml": "^5.4.3|^6.0",
|
||||||
"twig/twig": "^2.0|^3.0"
|
"twig/twig": "^2.0|^3.0"
|
||||||
|
@ -15655,7 +15667,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/symfony/maker-bundle/issues",
|
"issues": "https://github.com/symfony/maker-bundle/issues",
|
||||||
"source": "https://github.com/symfony/maker-bundle/tree/v1.48.0"
|
"source": "https://github.com/symfony/maker-bundle/tree/v1.49.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -15671,7 +15683,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2022-11-14T10:48:46+00:00"
|
"time": "2023-06-07T13:10:14+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/phpunit-bridge",
|
"name": "symfony/phpunit-bridge",
|
||||||
|
@ -16005,7 +16017,6 @@
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {
|
"stability-flags": {
|
||||||
"florianv/swap-bundle": 20,
|
"florianv/swap-bundle": 20,
|
||||||
"jbtronics/2fa-webauthn": 20,
|
|
||||||
"roave/security-advisories": 20
|
"roave/security-advisories": 20
|
||||||
},
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue