diff --git a/backend/internal/handler/webauthn.go b/backend/internal/handler/webauthn.go index e94db1f..ce81c4e 100644 --- a/backend/internal/handler/webauthn.go +++ b/backend/internal/handler/webauthn.go @@ -98,6 +98,8 @@ func verifyRegistrationHandler(c *gin.Context) { PublicKey: credential.PublicKey, Transport: credential.Transport, UserID: user.ID, + BackupEligible: credential.Flags.BackupEligible, + BackupState: credential.Flags.BackupState, } if err := common.DB.Create(&credentialToStore).Error; err != nil { utils.UnknownHandlerError(c, err) diff --git a/backend/internal/model/user.go b/backend/internal/model/user.go index bb2867c..36feb8f 100644 --- a/backend/internal/model/user.go +++ b/backend/internal/model/user.go @@ -35,6 +35,10 @@ func (u User) WebAuthnCredentials() []webauthn.Credential { AttestationType: credential.AttestationType, PublicKey: credential.PublicKey, Transport: credential.Transport, + Flags: webauthn.CredentialFlags{ + BackupState: credential.BackupState, + BackupEligible: credential.BackupEligible, + }, } } diff --git a/backend/internal/model/webauthn.go b/backend/internal/model/webauthn.go index 8211b70..94886f7 100644 --- a/backend/internal/model/webauthn.go +++ b/backend/internal/model/webauthn.go @@ -25,6 +25,9 @@ type WebauthnCredential struct { AttestationType string `json:"attestationType"` Transport AuthenticatorTransportList `json:"-"` + BackupEligible bool `json:"backupEligible"` + BackupState bool `json:"backupState"` + UserID string } diff --git a/backend/migrations/20240813211251_passkey_backup_flags..up.sql b/backend/migrations/20240813211251_passkey_backup_flags..up.sql new file mode 100644 index 0000000..fcb42a6 --- /dev/null +++ b/backend/migrations/20240813211251_passkey_backup_flags..up.sql @@ -0,0 +1,2 @@ +ALTER TABLE webauthn_credentials ADD COLUMN backup_eligible BOOLEAN NOT NULL DEFAULT FALSE; +ALTER TABLE webauthn_credentials ADD COLUMN backup_state BOOLEAN NOT NULL DEFAULT FALSE; \ No newline at end of file diff --git a/backend/migrations/20240813211251_passkey_backup_flags.down.sql b/backend/migrations/20240813211251_passkey_backup_flags.down.sql new file mode 100644 index 0000000..a7eb3fd --- /dev/null +++ b/backend/migrations/20240813211251_passkey_backup_flags.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE webauthn_credentials DROP COLUMN backup_eligible; +ALTER TABLE webauthn_credentials DROP COLUMN backup_state; \ No newline at end of file