-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mfa config has now its own database table * mfa config does not require RP config anymore * webauthn client for mfa uses rp from passkey config * update openapi specs to reflect changes Closes: #45
- Loading branch information
Stefan Jacobi
committed
Mar 25, 2024
1 parent
6f8b064
commit ab596c5
Showing
36 changed files
with
545 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package request | ||
|
||
import ( | ||
"github.com/go-webauthn/webauthn/protocol" | ||
"github.com/gofrs/uuid" | ||
"github.com/teamhanko/passkey-server/persistence/models" | ||
"time" | ||
) | ||
|
||
type CreateMFAConfigDto struct { | ||
Timeout int `json:"timeout" validate:"required,number"` | ||
UserVerification *protocol.UserVerificationRequirement `json:"user_verification" validate:"omitempty,oneof=required preferred discouraged"` | ||
Attachment *protocol.AuthenticatorAttachment `json:"attachment" validate:"omitempty,oneof=platform cross-platform"` | ||
AttestationPreference *protocol.ConveyancePreference `json:"attestation_preference" validate:"omitempty,oneof=none indirect direct enterprise"` | ||
ResidentKeyRequirement *protocol.ResidentKeyRequirement `json:"resident_key_requirement" validate:"omitempty,oneof=discouraged preferred required"` | ||
} | ||
|
||
func (dto *CreateMFAConfigDto) ToModel(configModel models.Config) models.MfaConfig { | ||
mfaConfigId, _ := uuid.NewV4() | ||
now := time.Now() | ||
|
||
mfaConfig := models.MfaConfig{ | ||
ID: mfaConfigId, | ||
ConfigID: configModel.ID, | ||
Timeout: dto.Timeout, | ||
CreatedAt: now, | ||
UpdatedAt: now, | ||
} | ||
|
||
if dto.AttestationPreference == nil { | ||
mfaConfig.AttestationPreference = protocol.PreferNoAttestation | ||
} else { | ||
mfaConfig.AttestationPreference = *dto.AttestationPreference | ||
} | ||
|
||
if dto.ResidentKeyRequirement == nil { | ||
mfaConfig.ResidentKeyRequirement = protocol.ResidentKeyRequirementDiscouraged | ||
} else { | ||
mfaConfig.ResidentKeyRequirement = *dto.ResidentKeyRequirement | ||
} | ||
|
||
if dto.UserVerification == nil { | ||
mfaConfig.UserVerification = protocol.VerificationPreferred | ||
} else { | ||
mfaConfig.UserVerification = *dto.UserVerification | ||
} | ||
|
||
if dto.Attachment == nil { | ||
mfaConfig.Attachment = protocol.CrossPlatform | ||
} else { | ||
mfaConfig.Attachment = *dto.Attachment | ||
} | ||
|
||
return mfaConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package response | ||
|
||
import ( | ||
"github.com/go-webauthn/webauthn/protocol" | ||
"github.com/teamhanko/passkey-server/persistence/models" | ||
) | ||
|
||
type GetMFAResponse struct { | ||
Timeout int `json:"timeout"` | ||
UserVerification protocol.UserVerificationRequirement `json:"user_verification"` | ||
Attachment protocol.AuthenticatorAttachment `json:"attachment"` | ||
AttestationPreference protocol.ConveyancePreference `json:"attestation_preference"` | ||
ResidentKeyRequirement protocol.ResidentKeyRequirement `json:"resident_key_requirement"` | ||
} | ||
|
||
func ToGetMFAResponse(webauthn *models.MfaConfig) GetMFAResponse { | ||
return GetMFAResponse{ | ||
Timeout: webauthn.Timeout, | ||
UserVerification: webauthn.UserVerification, | ||
Attachment: webauthn.Attachment, | ||
AttestationPreference: webauthn.AttestationPreference, | ||
ResidentKeyRequirement: webauthn.ResidentKeyRequirement, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.