Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 4.7.0 into 5.0.x #463

Merged
merged 25 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
86647fd
BE and BS flags support (#424)
Spomky Jun 21, 2023
49b5bbc
BS and BE flags added to the Symfony Token (#425)
Spomky Jun 21, 2023
8714844
Fix bundle extension classname (#429)
Spomky Jul 2, 2023
c53f585
Update scorecards.yml (#430)
Spomky Jul 2, 2023
69c7a16
Merge pull request #431 from web-auth/4.6.x
Spomky Jul 2, 2023
c3eae17
return transports in attestation response pk credential source
Spomky Jul 15, 2023
ca754d8
Merge pull request #435 from joostdebruijn/fix/add-transports
Spomky Jul 15, 2023
fb38183
Fix typos (#433)
szepeviktor Jul 15, 2023
3db3259
Fix wrong EdDSA key encoding (#437)
Spomky Jul 15, 2023
7e89cde
Merge up 4.6.x to 4.7.x
Spomky Jul 15, 2023
c295998
Merge pull request #439 from web-auth/temporary-branchhFjDEmnd
Spomky Jul 15, 2023
7ef9b7b
Fix Rector+ECS
Spomky Jul 15, 2023
8e9167b
Merge pull request #440 from web-auth/cs/fix-all
Spomky Jul 15, 2023
697c84f
Ability to register users without username or displayName (#443)
Spomky Jul 23, 2023
9c83a3f
Fixed composer keywords (#444)
Spomky Jul 23, 2023
3eeb057
JS deps updated (#446)
Spomky Jul 24, 2023
c9e54b7
Doc files updated (#445)
Spomky Jul 24, 2023
52b2774
Minor corrections (#447)
Spomky Jul 24, 2023
0e945db
Previous fix for eddsa key fail at authentication (#449)
Gashmob Jul 26, 2023
e5adcb1
Bugs fixed (#451)
Spomky Jul 27, 2023
080b81d
Sonarcloud Github Action (#452)
Spomky Jul 27, 2023
5f1eefd
Code Coverage for Sonarcloud (#453)
Spomky Jul 27, 2023
b2c2321
Code Coverage for Sonarcloud (#454)
Spomky Jul 27, 2023
8d78f43
New exclusions (#455)
Spomky Jul 27, 2023
87895ca
Deprecate DTOs/ValueObjects getters/setters in favor of direct acces …
Spomky Jul 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bugs fixed (#451)
Bugs fixed
  • Loading branch information
Spomky authored Jul 27, 2023
commit e5adcb10002a270d1e7b42d9663c19552dfea5c2
2 changes: 1 addition & 1 deletion bin/build_styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ glob(pattern, function (err, files) {
const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));

// Get the css source
const cssSourceRelative = pkg.config && pkg.config.css_source;
const cssSourceRelative = pkg.config?.css_source;

if (!cssSourceRelative) {
return;
Expand Down
16 changes: 10 additions & 6 deletions src/metadata-service/src/CertificateChain/CertificateToolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

class CertificateToolbox
{
private const PEM_HEADER = '-----BEGIN ';

private const PEM_FOOTER = '-----END ';

/**
* @param string[] $data
*
Expand All @@ -23,29 +27,29 @@ public static function fixPEMStructures(array $data, string $type = 'CERTIFICATE

public static function fixPEMStructure(string $data, string $type = 'CERTIFICATE'): string
{
if (str_contains($data, '-----BEGIN')) {
if (str_contains($data, self::PEM_HEADER)) {
return trim($data);
}
$pem = '-----BEGIN ' . $type . '-----' . PHP_EOL;
$pem = self::PEM_HEADER . $type . '-----' . PHP_EOL;
$pem .= chunk_split($data, 64, PHP_EOL);

return $pem . ('-----END ' . $type . '-----' . PHP_EOL);
return $pem . (self::PEM_FOOTER . $type . '-----' . PHP_EOL);
}

public static function convertPEMToDER(string $data): string
{
if (! str_contains($data, '-----BEGIN')) {
if (! str_contains($data, self::PEM_HEADER)) {
return $data;
}
$data = preg_replace('/[\-]{5}.*[\-]{5}[\r\n]*/', '', $data);
$data = preg_replace('/\-{5}.*\-{5}[\r\n]*/', '', $data);
$data = preg_replace("/[\r\n]*/", '', $data);

return Base64::decode(trim($data), true);
}

public static function convertDERToPEM(string $data, string $type = 'CERTIFICATE'): string
{
if (str_contains($data, '-----BEGIN')) {
if (str_contains($data, self::PEM_HEADER)) {
return $data;
}
$der = self::unusedBytesFix($data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ private function retrieveRevokedSerialNumbers(string $url): array
$crlData = $response->getBody()
->getContents();
$crl = UnspecifiedType::fromDER($crlData)->asSequence();
count($crl) === 3 || throw CertificateRevocationListException::create($url, 'Invalid CRL.');
count($crl) === 3 || throw CertificateRevocationListException::create($url);
$tbsCertList = $crl->at(0)
->asSequence();
count($tbsCertList) >= 6 || throw CertificateRevocationListException::create($url, 'Invalid CRL.');
count($tbsCertList) >= 6 || throw CertificateRevocationListException::create($url);
$list = $tbsCertList->at(5)
->asSequence();

return array_map(static function (UnspecifiedType $r) use ($url): string {
$sequence = $r->asSequence();
count($sequence) >= 1 || throw CertificateRevocationListException::create($url, 'Invalid CRL.');
count($sequence) >= 1 || throw CertificateRevocationListException::create($url);
return $sequence->at(0)
->asInteger()
->number();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
parent::__construct($message, $previous);
}

public static function create(string $url, string $message, ?Throwable $previous = null): self
public static function create(string $url, string $message = 'Invalid CRL.', ?Throwable $previous = null): self
{
return new self($url, $message, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

final class MetadataStatementLoadingException extends MetadataStatementException
{
public static function create(string $message, ?Throwable $previous = null): self
{
public static function create(
string $message = 'Unable to load the metadata statement',
?Throwable $previous = null
): self {
return new self($message, $previous);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public static function create(
public function list(): iterable
{
$this->loadData();
$this->statement !== null || throw MetadataStatementLoadingException::create(
'Unable to load the metadata statement'
);
$this->statement !== null || throw MetadataStatementLoadingException::create();
$aaguid = $this->statement->getAaguid();
if ($aaguid === null) {
yield from [];
Expand All @@ -70,19 +68,15 @@ public function list(): iterable
public function has(string $aaguid): bool
{
$this->loadData();
$this->statement !== null || throw MetadataStatementLoadingException::create(
'Unable to load the metadata statement'
);
$this->statement !== null || throw MetadataStatementLoadingException::create();

return $aaguid === $this->statement->getAaguid();
}

public function get(string $aaguid): MetadataStatement
{
$this->loadData();
$this->statement !== null || throw MetadataStatementLoadingException::create(
'Unable to load the metadata statement'
);
$this->statement !== null || throw MetadataStatementLoadingException::create();

if ($aaguid === $this->statement->getAaguid()) {
$this->dispatcher->dispatch(MetadataStatementFound::create($this->statement));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private function loadData(): void
}
}
} catch (Throwable) {
// Nothing to do
}

$this->loaded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use function file_get_contents;
use InvalidArgumentException;
use function is_array;
use RuntimeException;
use function sprintf;
use Webauthn\MetadataService\Exception\MetadataStatementLoadingException;
use Webauthn\MetadataService\Statement\MetadataStatement;

final class FolderResourceMetadataService implements MetadataService
Expand All @@ -28,7 +28,7 @@ public function __construct(string $rootPath)
public function list(): iterable
{
$files = glob($this->rootPath . DIRECTORY_SEPARATOR . '*');
is_array($files) || throw new RuntimeException('Unable to read files.');
is_array($files) || throw MetadataStatementLoadingException::create('Unable to read files.');
foreach ($files as $file) {
if (is_dir($file) || ! is_readable($file)) {
continue;
Expand All @@ -54,7 +54,7 @@ public function get(string $aaguid): MetadataStatement
$filename = $this->rootPath . DIRECTORY_SEPARATOR . $aaguid;
$data = trim(file_get_contents($filename));
$mds = MetadataStatement::createFromString($data);
$mds->getAaguid() !== null || throw new RuntimeException('Invalid Metadata Statement.');
$mds->getAaguid() !== null || throw MetadataStatementLoadingException::create('Invalid Metadata Statement.');

return $mds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public static function create(string $filename, bool $isBase64Encoded = false):
public function list(): iterable
{
$this->loadData();
$this->statement !== null || throw MetadataStatementLoadingException::create(
'Unable to load the metadata statement'
);
$this->statement !== null || throw MetadataStatementLoadingException::create();
$aaguid = $this->statement->getAaguid();
if ($aaguid === null) {
yield from [];
Expand All @@ -54,19 +52,15 @@ public function list(): iterable
public function has(string $aaguid): bool
{
$this->loadData();
$this->statement !== null || throw MetadataStatementLoadingException::create(
'Unable to load the metadata statement'
);
$this->statement !== null || throw MetadataStatementLoadingException::create();

return $aaguid === $this->statement->getAaguid();
}

public function get(string $aaguid): MetadataStatement
{
$this->loadData();
$this->statement !== null || throw MetadataStatementLoadingException::create(
'Unable to load the metadata statement'
);
$this->statement !== null || throw MetadataStatementLoadingException::create();

if ($aaguid === $this->statement->getAaguid()) {
$this->dispatcher->dispatch(MetadataStatementFound::create($this->statement));
Expand Down
52 changes: 49 additions & 3 deletions src/metadata-service/src/Statement/MetadataStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,64 @@ class MetadataStatement implements JsonSerializable
{
final public const KEY_PROTECTION_SOFTWARE = 'software';

final public const KEY_PROTECTION_SOFTWARE_INT = 0x0001;

final public const KEY_PROTECTION_HARDWARE = 'hardware';

final public const KEY_PROTECTION_HARDWARE_INT = 0x0002;

final public const KEY_PROTECTION_TEE = 'tee';

final public const KEY_PROTECTION_TEE_INT = 0x0004;

final public const KEY_PROTECTION_SECURE_ELEMENT = 'secure_element';

final public const KEY_PROTECTION_SECURE_ELEMENT_INT = 0x0008;

final public const KEY_PROTECTION_REMOTE_HANDLE = 'remote_handle';

final public const KEY_PROTECTION_REMOTE_HANDLE_INT = 0x0010;

final public const KEY_PROTECTION_TYPES = [
self::KEY_PROTECTION_SOFTWARE,
self::KEY_PROTECTION_HARDWARE,
self::KEY_PROTECTION_TEE,
self::KEY_PROTECTION_SECURE_ELEMENT,
self::KEY_PROTECTION_REMOTE_HANDLE,
];

final public const KEY_PROTECTION_TYPES_INT = [
self::KEY_PROTECTION_SOFTWARE_INT,
self::KEY_PROTECTION_HARDWARE_INT,
self::KEY_PROTECTION_TEE_INT,
self::KEY_PROTECTION_SECURE_ELEMENT_INT,
self::KEY_PROTECTION_REMOTE_HANDLE_INT,
];

final public const MATCHER_PROTECTION_SOFTWARE = 'software';

final public const MATCHER_PROTECTION_SOFTWARE_INT = 0x0001;

final public const MATCHER_PROTECTION_TEE = 'tee';

final public const MATCHER_PROTECTION_TEE_INT = 0x0002;

final public const MATCHER_PROTECTION_ON_CHIP = 'on_chip';

final public const MATCHER_PROTECTION_ON_CHIP_INT = 0x0004;

final public const MATCHER_PROTECTION_TYPES = [
self::MATCHER_PROTECTION_SOFTWARE,
self::MATCHER_PROTECTION_TEE,
self::MATCHER_PROTECTION_ON_CHIP,
];

final public const MATCHER_PROTECTION_TYPES_INT = [
self::MATCHER_PROTECTION_SOFTWARE_INT,
self::MATCHER_PROTECTION_TEE_INT,
self::MATCHER_PROTECTION_ON_CHIP_INT,
];

final public const ATTACHMENT_HINT_INTERNAL = 'internal';

final public const ATTACHMENT_HINT_EXTERNAL = 'external';
Expand Down Expand Up @@ -442,7 +486,9 @@ public static function createFromArray(array $data): self
$data['protocolFamily'],
$data['schema'],
array_map(static function ($upv): Version {
is_array($upv) || throw MetadataStatementLoadingException::create('Invalid Metadata Statement');
is_array($upv) || throw MetadataStatementLoadingException::create(
'Invalid Metadata Statement. The parameter "upv" shall be a list of objects.'
);

return Version::createFromArray($upv);
}, $data['upv']),
Expand All @@ -451,7 +497,7 @@ public static function createFromArray(array $data): self
$data['attestationTypes'],
array_map(static function ($userVerificationDetails): VerificationMethodANDCombinations {
is_array($userVerificationDetails) || throw MetadataStatementLoadingException::create(
'Invalid Metadata Statement'
'Invalid Metadata Statement. The parameter "userVerificationDetails" shall be a list of objects.'
);

return VerificationMethodANDCombinations::createFromArray($userVerificationDetails);
Expand All @@ -478,7 +524,7 @@ public static function createFromArray(array $data): self
if (isset($data['tcDisplayPNGCharacteristics'])) {
$tcDisplayPNGCharacteristics = $data['tcDisplayPNGCharacteristics'];
is_array($tcDisplayPNGCharacteristics) || throw MetadataStatementLoadingException::create(
'Invalid Metadata Statement'
'Invalid Metadata Statement. The parameter "tcDisplayPNGCharacteristics" shall be a list of objects.'
);
foreach ($tcDisplayPNGCharacteristics as $tcDisplayPNGCharacteristic) {
is_array($tcDisplayPNGCharacteristic) || throw MetadataStatementLoadingException::create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,88 @@ class VerificationMethodDescriptor implements JsonSerializable
{
final public const USER_VERIFY_PRESENCE_INTERNAL = 'presence_internal';

final public const USER_VERIFY_PRESENCE_INTERNAL_INT = 0x00000001;

final public const USER_VERIFY_FINGERPRINT_INTERNAL = 'fingerprint_internal';

final public const USER_VERIFY_FINGERPRINT_INTERNAL_INT = 0x00000002;

final public const USER_VERIFY_PASSCODE_INTERNAL = 'passcode_internal';

final public const USER_VERIFY_PASSCODE_INTERNAL_INT = 0x00000004;

final public const USER_VERIFY_VOICEPRINT_INTERNAL = 'voiceprint_internal';

final public const USER_VERIFY_VOICEPRINT_INTERNAL_INT = 0x00000008;

final public const USER_VERIFY_FACEPRINT_INTERNAL = 'faceprint_internal';

final public const USER_VERIFY_FACEPRINT_INTERNAL_INT = 0x00000010;

final public const USER_VERIFY_LOCATION_INTERNAL = 'location_internal';

final public const USER_VERIFY_LOCATION_INTERNAL_INT = 0x00000020;

final public const USER_VERIFY_EYEPRINT_INTERNAL = 'eyeprint_internal';

final public const USER_VERIFY_EYEPRINT_INTERNAL_INT = 0x00000040;

final public const USER_VERIFY_PATTERN_INTERNAL = 'pattern_internal';

final public const USER_VERIFY_PATTERN_INTERNAL_INT = 0x00000080;

final public const USER_VERIFY_HANDPRINT_INTERNAL = 'handprint_internal';

final public const USER_VERIFY_HANDPRINT_INTERNAL_INT = 0x00000100;

final public const USER_VERIFY_PASSCODE_EXTERNAL = 'passcode_external';

final public const USER_VERIFY_PASSCODE_EXTERNAL_INT = 0x00000800;

final public const USER_VERIFY_PATTERN_EXTERNAL = 'pattern_external';

final public const USER_VERIFY_PATTERN_EXTERNAL_INT = 0x00001000;

final public const USER_VERIFY_NONE = 'none';

final public const USER_VERIFY_NONE_INT = 0x00000200;

final public const USER_VERIFY_ALL = 'all';

final public const USER_VERIFY_ALL_INT = 0x00000400;

final public const USER_VERIFICATION_METHODS = [
self::USER_VERIFY_PRESENCE_INTERNAL,
self::USER_VERIFY_FINGERPRINT_INTERNAL,
self::USER_VERIFY_PASSCODE_INTERNAL,
self::USER_VERIFY_VOICEPRINT_INTERNAL,
self::USER_VERIFY_FACEPRINT_INTERNAL,
self::USER_VERIFY_LOCATION_INTERNAL,
self::USER_VERIFY_EYEPRINT_INTERNAL,
self::USER_VERIFY_PATTERN_INTERNAL,
self::USER_VERIFY_HANDPRINT_INTERNAL,
self::USER_VERIFY_PASSCODE_EXTERNAL,
self::USER_VERIFY_PATTERN_EXTERNAL,
self::USER_VERIFY_NONE,
self::USER_VERIFY_ALL,
];

final public const USER_VERIFICATION_METHODS_INT = [
self::USER_VERIFY_PRESENCE_INTERNAL_INT,
self::USER_VERIFY_FINGERPRINT_INTERNAL_INT,
self::USER_VERIFY_PASSCODE_INTERNAL_INT,
self::USER_VERIFY_VOICEPRINT_INTERNAL_INT,
self::USER_VERIFY_FACEPRINT_INTERNAL_INT,
self::USER_VERIFY_LOCATION_INTERNAL_INT,
self::USER_VERIFY_EYEPRINT_INTERNAL_INT,
self::USER_VERIFY_PATTERN_INTERNAL_INT,
self::USER_VERIFY_HANDPRINT_INTERNAL_INT,
self::USER_VERIFY_PASSCODE_EXTERNAL_INT,
self::USER_VERIFY_PATTERN_EXTERNAL_INT,
self::USER_VERIFY_NONE_INT,
self::USER_VERIFY_ALL_INT,
];

private readonly string $userVerificationMethod;

public function __construct(
Expand Down
5 changes: 3 additions & 2 deletions src/stimulus/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { startAuthentication, startRegistration } from '@simplewebauthn/browser'

class default_1 extends Controller {
connect() {
var _a, _b;
const options = {
requestResultUrl: this.requestResultUrlValue,
requestOptionsUrl: this.requestOptionsUrlValue,
requestSuccessRedirectUri: this.requestSuccessRedirectUriValue || null,
requestSuccessRedirectUri: (_a = this.requestSuccessRedirectUriValue) !== null && _a !== void 0 ? _a : null,
creationResultUrl: this.creationResultUrlValue,
creationOptionsUrl: this.creationOptionsUrlValue,
creationSuccessRedirectUri: this.creationSuccessRedirectUriValue || null,
creationSuccessRedirectUri: (_b = this.creationSuccessRedirectUriValue) !== null && _b !== void 0 ? _b : null,
};
this._dispatchEvent('webauthn:connect', { options });
}
Expand Down
Loading