The WebAuthn.Net.Storage.MySql package requires a specific database schema to store credential data. This implementation is intended for MySQL 8.0+; MySQL 5.7 is not supported.
Because this library is designed to be integrated into existing applications, you must decide how to apply these migrations (e.g., using Entity Framework, FluentMigrator, or manual scripts).
Critical Requirement: You must ensure a unique index exists on the combination of RpId, UserHandle, and CredentialId, as this combination uniquely identifies a public key.
CREATE TABLE `CredentialRecords`
(
`Id` binary(16) NOT NULL,
`RpId` varchar(256) NOT NULL,
`UserHandle` varbinary(128) NOT NULL,
`CredentialId` varbinary(1024) NOT NULL,
`Type` int NOT NULL,
`Kty` int NOT NULL,
`Alg` int NOT NULL,
`Ec2Crv` int NULL,
`Ec2X` varbinary(256) NULL,
`Ec2Y` varbinary(256) NULL,
`RsaModulusN` varbinary(1024) NULL,
`RsaExponentE` varbinary(32) NULL,
`OkpCrv` int NULL,
`OkpX` varbinary(32) NULL,
`SignCount` int unsigned NOT NULL,
`Transports` json NOT NULL,
`UvInitialized` tinyint(1) NOT NULL,
`BackupEligible` tinyint(1) NOT NULL,
`BackupState` tinyint(1) NOT NULL,
`AttestationObject` longblob NULL,
`AttestationClientDataJson` longblob NULL,
`Description` varchar(200) NULL,
`CreatedAtUnixTime` bigint NOT NULL,
`UpdatedAtUnixTime` bigint NOT NULL,
CONSTRAINT `PK_CredentialRecords` PRIMARY KEY (`Id`)
) CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
CREATE UNIQUE INDEX `IX_CredentialRecords_UserHandle_CredentialId_RpId` ON `CredentialRecords`
(
`UserHandle`,
`CredentialId`,
`RpId`
);
CREATE UNIQUE INDEX `IX_CredentialRecords_CredentialId_RpId` ON `CredentialRecords`
(
`CredentialId`,
`RpId`
);