open-vault/helper/identity/mfa/mfa.go
Josh Black e83471d7de
Login MFA (#14025)
* Login MFA

* ENT OSS segragation (#14088)

* Delete method id if not used in an MFA enforcement config (#14063)

* Delete an MFA methodID only if it is not used by an MFA enforcement config

* Fixing a bug: mfa/validate is an unauthenticated path, and goes through the handleLoginRequest path

* adding use_passcode field to DUO config (#14059)

* add changelog

* preventing replay attack on MFA passcodes (#14056)

* preventing replay attack on MFA passcodes

* using %w instead of %s for error

* Improve CLI command for login mfa (#14106)

CLI prints a warning message indicating the login request needs to get validated

* adding the validity period of a passcode to error messages (#14115)

* PR feedback

* duo to handle preventing passcode reuse

Co-authored-by: hghaf099 <83242695+hghaf099@users.noreply.github.com>
Co-authored-by: hamid ghaf <hamid@hashicorp.com>
2022-02-17 13:08:51 -08:00

46 lines
954 B
Go

package mfa
import (
"fmt"
"github.com/golang/protobuf/proto"
)
func (c *Config) Clone() (*Config, error) {
if c == nil {
return nil, fmt.Errorf("nil config")
}
marshaledConfig, err := proto.Marshal(c)
if err != nil {
return nil, fmt.Errorf("failed to marshal config: %w", err)
}
var clonedConfig Config
err = proto.Unmarshal(marshaledConfig, &clonedConfig)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
return &clonedConfig, nil
}
func (c *MFAEnforcementConfig) Clone() (*MFAEnforcementConfig, error) {
if c == nil {
return nil, fmt.Errorf("nil config")
}
marshaledConfig, err := proto.Marshal(c)
if err != nil {
return nil, fmt.Errorf("failed to marshal config: %w", err)
}
var clonedConfig MFAEnforcementConfig
err = proto.Unmarshal(marshaledConfig, &clonedConfig)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
return &clonedConfig, nil
}