diff --git a/selfservice/mfa/questions/config.go b/selfservice/mfa/questions/config.go deleted file mode 100644 index 384ff0f558d2..000000000000 --- a/selfservice/mfa/questions/config.go +++ /dev/null @@ -1,6 +0,0 @@ -package questions - -type RecoverySecurityQuestion struct { - ID string `json:"id"` - Label string `json:"label"` -} diff --git a/selfservice/mfa/questions/config_test.go b/selfservice/mfa/questions/config_test.go deleted file mode 100644 index 9ae28e9de2e6..000000000000 --- a/selfservice/mfa/questions/config_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package questions - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestConfig(t *testing.T) { - t.Run("method=recovery", func(t *testing.T) { - t.SkipNow() - assert.EqualValues(t, []RecoverySecurityQuestion{{ID: "foo", Label: "bar"}}, - nil) - // p.SelfServiceRecoverySecurityQuestions()) - }) -} diff --git a/selfservice/mfa/questions/identity.go b/selfservice/mfa/questions/identity.go deleted file mode 100644 index 91635102b94b..000000000000 --- a/selfservice/mfa/questions/identity.go +++ /dev/null @@ -1,32 +0,0 @@ -package questions - -import ( - "context" - "time" - - "github.com/ory/kratos/corp" - - "github.com/gofrs/uuid" -) - -type ( - RecoverySecurityAnswers []RecoverySecurityAnswer - RecoverySecurityAnswer struct { - // required: true - ID uuid.UUID `json:"id" db:"id" faker:"-"` - - Key string `json:"key" db:"key"` - Answer string `json:"answer" db:"answer"` - - // IdentityID is a helper struct field for gobuffalo.pop. - IdentityID uuid.UUID `json:"-" faker:"-" db:"identity_id"` - // CreatedAt is a helper struct field for gobuffalo.pop. - CreatedAt time.Time `json:"-" faker:"-" db:"created_at"` - // UpdatedAt is a helper struct field for gobuffalo.pop. - UpdatedAt time.Time `json:"-" faker:"-" db:"updated_at"` - } -) - -func (a RecoverySecurityAnswers) TableName(ctx context.Context) string { - return corp.ContextualizeTableName(ctx, "identity_recovery_addresses") -} diff --git a/selfservice/mfa/questions/manager.go b/selfservice/mfa/questions/manager.go deleted file mode 100644 index ffeb51f1aee0..000000000000 --- a/selfservice/mfa/questions/manager.go +++ /dev/null @@ -1,97 +0,0 @@ -// nolint -package questions - -import ( - "context" - "regexp" - "strings" - - "github.com/ory/kratos/driver/config" - "github.com/ory/kratos/hash" - "github.com/ory/kratos/identity" - "github.com/ory/kratos/selfservice/form" -) - -type ( - ManagementProvider interface { - RecoveryManager() *Manager - } - managerDependencies interface { - hash.HashProvider - } - Manager struct { - c config.Provider - d managerDependencies - } -) - -var collapseNonAlphanumeric = regexp.MustCompile(`[^a-zA-Z\d\s:]+`) - -func normalizeAnswer(in string) []byte { - return []byte(collapseNonAlphanumeric.ReplaceAllString(strings.ToLower(strings.TrimSpace(in)), " ")) -} - -func (m *Manager) SetSecurityFormFields(ctx context.Context, i *identity.Identity, prefix string, htmlf *form.HTMLForm) error { - if len(prefix) > 0 { - prefix = prefix + "." - } - - // for _, question := range i.RecoverySecurityAnswers { - // htmlf.SetField(form.Field{Name: prefix + question.Key, Type: "text", Required: true}) - // } - return nil -} - -// func (m *Manager) CompareSecurityQuestions(ctx context.Context, question identity.RecoverySecurityAnswer, answer string) error { -// return m.d.Hasher().Compare([]byte(answer), normalizeAnswer(question.Answer)) -// } - -func (m *Manager) HashSecurityQuestions(i *identity.Identity, answers map[string]string) error { - // var result identity.RecoverySecurityAnswers - // - // for key, answer := range answers { - // hashed, err := m.d.Hasher().Generate(normalizeAnswer(answer)) - // if err != nil { - // return err - // } - // - // result = append(result, - // identity.RecoverySecurityAnswer{ID: x.NewUUID(), Key: key, Answer: string(hashed), IdentityID: i.ID}) - // } - // - // i.RecoverySecurityAnswers = result - return nil -} - -func (m *Manager) SetSecurityAnswers(ctx context.Context, i *identity.Identity, answers map[string]string, validationPrefix string) error { - // // Validation - // for _, question := range m.c.SelfServiceRecoverySecurityQuestions() { - // var found bool - // for id, answer := range answers { - // if id == question.ID { - // expected := 6 - // answer = normalizeAnswer(answer) - // - // if actual := utf8.RuneCountInString(answer); actual < expected { - // return errors.WithStack(&jsonschema.ValidationError{ - // Message: fmt.Sprintf("length must be >= %d, but got %s (%d) after normalization", expected, answer, actual), - // InstancePtr: validationPrefix + id, - // }) - // } - // - // found = true - // i.RecoverySecurityAnswers = append(i.RecoverySecurityAnswers, identity.RecoverySecurityAnswer{ - // Key: id, Answer: answer, - // IdentityID: i.ID, - // }) - // break - // } - // } - // - // if !found { - // return schema.NewRequiredError(validationPrefix, question.ID) - // } - // } - - return nil -} diff --git a/selfservice/mfa/questions/recovery.go b/selfservice/mfa/questions/recovery.go deleted file mode 100644 index ceb44f01ef7d..000000000000 --- a/selfservice/mfa/questions/recovery.go +++ /dev/null @@ -1,13 +0,0 @@ -package questions - -// func (s *StrategyLink) answerSecurityQuestions(w http.ResponseWriter, r *http.Request, req *Request) { -// for _, question := range req.RecoveredIdentity.RecoverySecurityAnswers { -// answer := r.PostForm.Get(securityQuestionPrefix + "." + question.Key) -// if len(answer) == 0 { -// s.handleError(w, r, req, schema.NewRequiredError("#/"+securityQuestionPrefix, question.Key)) -// return -// } -// -// s.d.RecoveryManager().CompareSecurityQuestions(r.Context(),question,answer) -// } -// } diff --git a/selfservice/mfa/questions/text.go b/selfservice/mfa/questions/text.go deleted file mode 100644 index 2f449bb4b184..000000000000 --- a/selfservice/mfa/questions/text.go +++ /dev/null @@ -1,10 +0,0 @@ -package questions - -// func NewRecoveryAskSecurityQuestions() *Message { -// return &Message{ -// ID: InfoSelfServiceRecoveryAskSecurityQuestions, -// Type: Info, -// Text: "Please answer the following questions to verify it is really you. These are your questions set up during registration or when you updated your profile.", -// } -// } -//