Files
hanko/backend/dto/webauthn.go
Frederic Jahn c264108f87 Admin api changes (#1974)
* feat: return mfa only flag

* feat: add webauthn admin handler

* feat: add webauthn credential handler to router

* feat: add password mgmt admin endpoints

* feat: add sessions admin handler

* feat: add otp admin handler

* feat: add otp to admin user dto

* test: add admin password handler test

* test: add admin webauthn handler test

* test: add admin session handler test

* test: add admin otp handler test

* chore: merge both loadDto functions

* tests: fix test name typos
2024-12-03 11:22:52 +01:00

43 lines
1.3 KiB
Go

package dto
import (
"github.com/gofrs/uuid"
"github.com/teamhanko/hanko/backend/persistence/models"
"time"
)
type WebauthnCredentialUpdateRequest struct {
Name *string `json:"name"`
}
type WebauthnCredentialResponse struct {
ID string `json:"id"`
Name *string `json:"name,omitempty"`
PublicKey string `json:"public_key"`
AttestationType string `json:"attestation_type"`
AAGUID uuid.UUID `json:"aaguid"`
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
Transports []string `json:"transports"`
BackupEligible bool `json:"backup_eligible"`
BackupState bool `json:"backup_state"`
MFAOnly bool `json:"mfa_only"`
}
// FromWebauthnCredentialModel Converts the DB model to a DTO object
func FromWebauthnCredentialModel(c *models.WebauthnCredential) *WebauthnCredentialResponse {
return &WebauthnCredentialResponse{
ID: c.ID,
Name: c.Name,
PublicKey: c.PublicKey,
AttestationType: c.AttestationType,
AAGUID: c.AAGUID,
LastUsedAt: c.LastUsedAt,
CreatedAt: c.CreatedAt,
Transports: c.Transports.GetNames(),
BackupEligible: c.BackupEligible,
BackupState: c.BackupState,
MFAOnly: c.MFAOnly,
}
}