able-dream-62808
11/11/2024, 10:45 AMbrief-egg-61061
11/11/2024, 10:45 AMbrief-egg-61061
11/11/2024, 10:45 AMable-dream-62808
11/11/2024, 10:47 AMgreen-librarian-85729
11/13/2024, 1:52 PMbrief-egg-61061
11/13/2024, 1:52 PMbrief-egg-61061
11/13/2024, 1:53 PMjson { "$id": "<https://example.com/registration.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "username": { "type": "string", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true }, "webauthn": { "identifier": true }, "totp": { "account_name": true }, "passkey": { "display_name": true } } } }, "email": { "type": "string", "format": "email", "<http://ory.sh/kratos|ory.sh/kratos>": { "recovery": { "via": "email" } } } } } } }
In this updated configuration, we've added the <http://ory.sh/kratos|ory.sh/kratos>
extension to the email field with the recovery
option set to use email. This allows you to send recovery codes to the registered email addresses while still using the username as the primary identifier for authentication. [Recovery address](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#recovery-address) Remember to also enable the recovery flow in your Ory Kratos configuration: yaml selfservice: flows: recovery: enabled: true ui_url: <http://127.0.0.1:4455/recovery>
[Account activation and email verification settings](https://www.ory.sh/docs/kratos/self-hosted/account-activation-email-verification) With this setup, users can initiate account recovery using their email address, even though the username is used as the primary identifier for authentication. Keep in mind that allowing non-unique email addresses might complicate the recovery process, as multiple accounts could potentially be associated with the same email. You may need to implement additional logic in your application to handle such cases.green-librarian-85729
11/13/2024, 2:06 PMbrief-egg-61061
11/13/2024, 2:06 PMbrief-egg-61061
11/13/2024, 2:06 PMidentity_recovery_addresses
entity is not created in the database, the recovery email cannot be sent out. This is indeed a potential issue with the configuration we discussed earlier. Let me explain why this happens and how we can address it. The reason for this issue is that we didn't explicitly set the email as a recovery address in our identity schema. To fix this, we need to modify our identity schema to include the email as both a recovery and verification address. Here's how we can update the schema: json { "$id": "<https://example.com/registration.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "username": { "type": "string", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true }, "webauthn": { "identifier": true }, "totp": { "account_name": true }, "passkey": { "display_name": true } } } }, "email": { "type": "string", "format": "email", "<http://ory.sh/kratos|ory.sh/kratos>": { "verification": { "via": "email" }, "recovery": { "via": "email" } } } }, "required": ["email"] } } }
In this updated schema, we've added both verification
and recovery
to the <http://ory.sh/kratos|ory.sh/kratos>
extension for the email field. This ensures that the email is used for both verification and recovery purposes. [Import identities](https://www.ory.sh/docs/kratos/manage-identities/import-user-accounts-identities) By adding these extensions, Ory Kratos will create the necessary entries in the identity_recovery_addresses
table when an identity is created or updated. This will allow the recovery email to be sent out when needed. Additionally, make sure that your Ory Kratos configuration has the recovery flow enabled: yaml selfservice: flows: recovery: enabled: true ui_url: <http://127.0.0.1:4455/recovery>
[Account activation and email verification settings](https://www.ory.sh/docs/kratos/self-hosted/account-activation-email-verification) With these changes, the identity_recovery_addresses
entity should be created in the database, and recovery emails should be able to be sent out successfully. Remember, if you're updating an existing system, you may need to migrate existing identities to include the recovery addresses. You can do this by updating the identities through the Ory Kratos API or by directly modifying the database (though the API method is recommended for safety).green-librarian-85729
11/13/2024, 2:26 PMbrief-egg-61061
11/13/2024, 2:26 PMbrief-egg-61061
11/13/2024, 2:26 PM