mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-29 15:49:41 +08:00
* feat: create otp_secrets table * feat: create otp secret model * feat: add mfa_only column to webauthn_credentials table * feat: add mfa only field to webauthn credential model * feat: add mfa config (#1607) * feat: add otp secret persister (#1613) * feat: MFA usage sub flow (#1614) * feat: add mfa-usage sub-flow --------- Co-authored-by: Lennart Fleischmann <67686424+lfleischmann@users.noreply.github.com> * feat: include platform authenticator availybility in the preflight flow (#1615) * feat: add mfa creation subflow * feat: adjust registration flow * feat: integrate mfa usage sub-flow * feat: add pages for mfa (#1622) * feat: profile flow adjustments for mfa support * fix: suspension logic for mfa deletion actions * feat: use dedicated action for security key creation options * fix: mfa method stash entry can be stale on profile flow The mfa_creation subflow sets an mfa_method stash value so that when creating and persisting the credential the mfa_only flag can be set correctly in the hook responsible for that. But the profile flow never "ends" and and returns to the initial state so I can also register a passkey afterwards. The mfa_method stash key remains on the stash but is used in the hook nonetheless, so the passkey is incorrectly recognized as a security key. The mfa_method key is now deleted after successfully persisting the credential/security_key. This should not have an effect on the login flow because the mfa_creation subflow is the last subflow to be executed. It also should not affect the registration flow, because the hook is not applied in the registration flow (persistence of data is all handled in the create_user hook). * feat: add new icons and english translations (#1626) * fix: credential id encoding corrected (#1628) * feat: add audit logs for mfa creation * feat: add a skip link to the mfa method chooser (#1630) * feat: save the security key during login (#1629) * feat: show security keys in profile * feat: add authenticator app management to profile (#1633) * feat: add authenticator app management to profile * feat: passkey counts as second factor * feat: prohibit security key first factor usage * feat: add all WA creds to exclude list on registration * refactor: mfa stash entries and webauthn credential persistence Renames MFA stash entry for indicating usage (login) method to make its meaning more explicit. Also removes code persisting a webauthn credential from the attestation verification action in the onboarding flow because this is already done by a shared hook. * refactor: simplify WA creation call Co-authored-by: bjoern-m <56024829+bjoern-m@users.noreply.github.com> * chore: adjust mfa flow * fix: mfa onboarding always shown during login * fix: mfa onboarding not shown after password or email creation during login * fix: mfa onboarding not shown without user detail onboarding * fix: correct skip/back behaviour * feat: reuse generated otp secret when the code is invalid * chore: skip mfa prompt if the user only has a passkey * chore: adjust login flow * chore: skip mfa prompt if the user only has a passkey * chore: refactor and improve mfa onboarding * fix: no mfa onboarding when passwords and passkeys are disabled * fix: only show mfa onbooarding once * feat: add a function to the flowpilot to check whether a state has been visited * chore: adjust recovery flow (#1655) * feat: disable password, passcode endpoints when mfa enabled * Feat: remember last used login method (#1674) * chore: remove omitempty from boolean (#1676) * chore: improved error handling (#1679) * chore: improved error handling * feat: add missing translations (#1681) * feat: update aaguid list (#1678) * fix: do not suspend webauthn action for MFA (#1778) Do not suspend the `webauthn_verify_attestation_response` action when passkeys are disabled, but security keys and MFA are enabled. * fix: change texts (#1785) Change texts regarding security creation to be more consistent across the flows and to be more precise. * Fix: UI issues (#1846) * fix: loading spinner alignment corrected * fix: auth app deletion link is shown while deletion is not allowed * Chore: remove test persister (#1876) * chore: remove deprecated test persister * chore: replace test persister calls * chore: add saml state fixtures * Update backend/flow_api/services/webauthn.go Co-authored-by: Frederic Jahn <frederic.jahn@hanko.io> * Update backend/dto/profile.go Co-authored-by: Frederic Jahn <frederic.jahn@hanko.io> * fix: otp validation uses the rate limiter key for passwords * chore: add otp-limits to the default config * chore: add explanation for 'UserVerification' setting on security keys --------- Co-authored-by: Lennart Fleischmann <lennart.fleischmann@hanko.io> Co-authored-by: Lennart Fleischmann <67686424+lfleischmann@users.noreply.github.com> Co-authored-by: Frederic Jahn <frederic.jahn@hanko.io>
93 lines
2.6 KiB
Go
93 lines
2.6 KiB
Go
package flowpilot
|
|
|
|
import (
|
|
"github.com/gofrs/uuid"
|
|
)
|
|
|
|
// defaultFlowContext is the default implementation of the flowContext interface.
|
|
type defaultFlowContext struct {
|
|
payload payload // JSONManager for payload data.
|
|
stash stash // JSONManager for stash data.
|
|
flow defaultFlow // The associated defaultFlow instance.
|
|
dbw flowDBWrapper // Wrapped FlowDB instance with additional functionality.
|
|
flowModel *FlowModel // The current FlowModel.
|
|
}
|
|
|
|
// GetFlowID returns the unique ID of the current flow.
|
|
func (fc *defaultFlowContext) GetFlowID() uuid.UUID {
|
|
return fc.flowModel.ID
|
|
}
|
|
|
|
// GetInitialState returns the initial state of the flow.
|
|
func (fc *defaultFlowContext) GetInitialState() StateName {
|
|
return fc.flow.initialStateNames[0]
|
|
}
|
|
|
|
// GetCurrentState returns the current state of the flow.
|
|
func (fc *defaultFlowContext) GetCurrentState() StateName {
|
|
return fc.stash.getStateName()
|
|
}
|
|
|
|
func (fc *defaultFlowContext) GetScheduledStates() []StateName {
|
|
return fc.stash.getScheduledStateNames()
|
|
}
|
|
|
|
// CurrentStateEquals returns true, when one of the given stateNames matches the current state name.
|
|
func (fc *defaultFlowContext) CurrentStateEquals(stateNames ...StateName) bool {
|
|
for _, s := range stateNames {
|
|
if s == fc.stash.getStateName() {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (fc *defaultFlowContext) IsStateScheduled(name StateName) bool {
|
|
for _, state := range fc.stash.getScheduledStateNames() {
|
|
if state == name {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (fc *defaultFlowContext) StateVisited(name StateName) bool {
|
|
return fc.stash.stateVisited(name)
|
|
}
|
|
|
|
// GetPreviousState returns the previous state of the flow.
|
|
func (fc *defaultFlowContext) GetPreviousState() StateName {
|
|
return fc.stash.getPreviousStateName()
|
|
}
|
|
|
|
// IsPreviousState returns true if the previous state equals the given name
|
|
func (fc *defaultFlowContext) IsPreviousState(name StateName) bool {
|
|
return fc.stash.getPreviousStateName() == name
|
|
}
|
|
|
|
// GetErrorState returns the designated error state of the flow.
|
|
func (fc *defaultFlowContext) GetErrorState() StateName {
|
|
return fc.flow.errorStateName
|
|
}
|
|
|
|
// Stash returns the JSONManager for accessing stash data.
|
|
func (fc *defaultFlowContext) Stash() stash {
|
|
return fc.stash
|
|
}
|
|
|
|
// Get returns the context value with the given name.
|
|
func (fc *defaultFlowContext) Get(name string) interface{} {
|
|
return fc.flow.contextValues[name]
|
|
}
|
|
|
|
// GetFlowName returns the name of the current flow.
|
|
func (fc *defaultFlowContext) GetFlowName() FlowName {
|
|
return fc.flow.name
|
|
}
|
|
|
|
// IsFlow returns true if the name matches the current flow name.
|
|
func (fc *defaultFlowContext) IsFlow(name FlowName) bool {
|
|
return fc.flow.name == name
|
|
}
|