-
-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch implements the account recovery with endpoints such as "Init Account Recovery", a new config value `urls.recovery_ui` and so on. Additionally, some refactoring was made to DRY code and make naming consistent. As part of dependency upgrades, structured logging has also improved and an audit trail prototype has been added (currently streams to stderr only). Closes #37 BREAKING CHANGES: * Applying this patch requires running SQL Migrations. * The field `identity.addresses` has moved to `identity.verifiable_addresses`. A new field has been added `identity.recovery_addresses`. Configuration key `selfservice.verify` was renamed to `selfservice.verification`. Configuration key `selfservice.verification.link_lifespan` has been merged with `selfservice.verification.request_lifespan`.
- Loading branch information
Showing
196 changed files
with
3,629 additions
and
968 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package template | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/ory/kratos/driver/configuration" | ||
) | ||
|
||
type ( | ||
RecoveryInvalid struct { | ||
c configuration.Provider | ||
m *RecoveryInvalidModel | ||
} | ||
RecoveryInvalidModel struct { | ||
To string | ||
} | ||
) | ||
|
||
func NewRecoveryInvalid(c configuration.Provider, m *RecoveryInvalidModel) *RecoveryInvalid { | ||
return &RecoveryInvalid{c: c, m: m} | ||
} | ||
|
||
func (t *RecoveryInvalid) EmailRecipient() (string, error) { | ||
return t.m.To, nil | ||
} | ||
|
||
func (t *RecoveryInvalid) EmailSubject() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "recovery/invalid/email.subject.gotmpl"), t.m) | ||
} | ||
|
||
func (t *RecoveryInvalid) EmailBody() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "recovery/invalid/email.body.gotmpl"), t.m) | ||
} |
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 template_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ory/kratos/courier/template" | ||
"github.com/ory/kratos/internal" | ||
) | ||
|
||
func TestRecoverInvalid(t *testing.T) { | ||
conf, _ := internal.NewFastRegistryWithMocks(t) | ||
tpl := template.NewRecoveryInvalid(conf, &template.RecoveryInvalidModel{}) | ||
|
||
rendered, err := tpl.EmailBody() | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, rendered) | ||
|
||
rendered, err = tpl.EmailSubject() | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, rendered) | ||
} |
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,34 @@ | ||
package template | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/ory/kratos/driver/configuration" | ||
) | ||
|
||
type ( | ||
RecoveryValid struct { | ||
c configuration.Provider | ||
m *RecoveryValidModel | ||
} | ||
RecoveryValidModel struct { | ||
To string | ||
RecoveryURL string | ||
} | ||
) | ||
|
||
func NewRecoveryValid(c configuration.Provider, m *RecoveryValidModel) *RecoveryValid { | ||
return &RecoveryValid{c: c, m: m} | ||
} | ||
|
||
func (t *RecoveryValid) EmailRecipient() (string, error) { | ||
return t.m.To, nil | ||
} | ||
|
||
func (t *RecoveryValid) EmailSubject() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "recovery/valid/email.subject.gotmpl"), t.m) | ||
} | ||
|
||
func (t *RecoveryValid) EmailBody() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "recovery/valid/email.body.gotmpl"), t.m) | ||
} |
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 template_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ory/kratos/courier/template" | ||
"github.com/ory/kratos/internal" | ||
) | ||
|
||
func TestRecoverValid(t *testing.T) { | ||
conf, _ := internal.NewFastRegistryWithMocks(t) | ||
tpl := template.NewRecoveryValid(conf, &template.RecoveryValidModel{}) | ||
|
||
rendered, err := tpl.EmailBody() | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, rendered) | ||
|
||
rendered, err = tpl.EmailSubject() | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, rendered) | ||
} |
9 changes: 9 additions & 0 deletions
9
courier/template/templates/recovery/invalid/email.body.gotmpl
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,9 @@ | ||
Hi, | ||
|
||
you (or someone else) entered this email address when trying to recover access to an account. | ||
|
||
However, this email address is not on our database of registered users and therefore the attempt has failed. | ||
|
||
If this was you, check if you signed up using a different address. | ||
|
||
If this was not you, please ignore this email. |
1 change: 1 addition & 0 deletions
1
courier/template/templates/recovery/invalid/email.subject.gotmpl
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 @@ | ||
Account access attempted |
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,5 @@ | ||
Hi, | ||
|
||
please recover your account by clicking the following link: | ||
|
||
<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a> |
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 @@ | ||
Recover your account |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../templates/verify/valid/email.body.gotmpl → ...ates/verification/valid/email.body.gotmpl
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Hi, please verify your account by clicking the following link: | ||
|
||
<a href="{{ .VerifyURL }}">{{ .VerifyURL }}</a> | ||
<a href="{{ .VerificationURL }}">{{ .VerificationURL }}</a> |
File renamed without changes.
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,33 @@ | ||
package template | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/ory/kratos/driver/configuration" | ||
) | ||
|
||
type ( | ||
VerificationInvalid struct { | ||
c configuration.Provider | ||
m *VerificationInvalidModel | ||
} | ||
VerificationInvalidModel struct { | ||
To string | ||
} | ||
) | ||
|
||
func NewVerificationInvalid(c configuration.Provider, m *VerificationInvalidModel) *VerificationInvalid { | ||
return &VerificationInvalid{c: c, m: m} | ||
} | ||
|
||
func (t *VerificationInvalid) EmailRecipient() (string, error) { | ||
return t.m.To, nil | ||
} | ||
|
||
func (t *VerificationInvalid) EmailSubject() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "verification/invalid/email.subject.gotmpl"), t.m) | ||
} | ||
|
||
func (t *VerificationInvalid) EmailBody() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "verification/invalid/email.body.gotmpl"), t.m) | ||
} |
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,34 @@ | ||
package template | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/ory/kratos/driver/configuration" | ||
) | ||
|
||
type ( | ||
VerificationValid struct { | ||
c configuration.Provider | ||
m *VerificationValidModel | ||
} | ||
VerificationValidModel struct { | ||
To string | ||
VerificationURL string | ||
} | ||
) | ||
|
||
func NewVerificationValid(c configuration.Provider, m *VerificationValidModel) *VerificationValid { | ||
return &VerificationValid{c: c, m: m} | ||
} | ||
|
||
func (t *VerificationValid) EmailRecipient() (string, error) { | ||
return t.m.To, nil | ||
} | ||
|
||
func (t *VerificationValid) EmailSubject() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "verification/valid/email.subject.gotmpl"), t.m) | ||
} | ||
|
||
func (t *VerificationValid) EmailBody() (string, error) { | ||
return loadTextTemplate(filepath.Join(t.c.CourierTemplatesRoot(), "verification/valid/email.body.gotmpl"), t.m) | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.