narrow-hospital-35452
10/27/2024, 12:22 PMbrief-egg-61061
10/27/2024, 12:22 PMbrief-egg-61061
10/27/2024, 12:22 PMjson { "$id": "<https://schemas.ory.sh/presets/kratos/quickstart/phone-password/identity.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "email": { "type": "string", "title": "E-Mail", "format": "email", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true } }, "verification": { "via": "email" } } }, "phone": { "type": "string", "title": "Phone number", "format": "tel", "<http://ory.sh/kratos|ory.sh/kratos>": { "verification": { "via": "sms" } } } }, "additionalProperties": false } } }
This schema allows for verification via both email and SMS [Phone number verification](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#phone-number-verification). 2. Ensure you have configured both email and SMS channels in your Ory configuration. For email, you'll need to set up an SMTP provider [Sending emails](https://www.ory.sh/docs/kratos/emails-sms/sending-emails-smtp). For SMS, you'll need to configure an SMS gateway [SMS documentation](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 3. With this setup, Ory Kratos will be able to send verification messages to both email and phone numbers. The system will use the appropriate template for each method: - For email: verification_code.valid
or verification.valid
(depending on whether you're using code or link method) - For SMS: verification_code.valid
(SMS typically uses the code method) [Built-in templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#built-in-templates) Remember that the user will need to verify both their email and phone number separately to have both marked as verified in their account. This configuration allows Ory Kratos to send verification to phone via SMS, while still maintaining the ability to send verifications via email as well.narrow-hospital-35452
10/28/2024, 7:17 PMbrief-egg-61061
10/28/2024, 7:17 PMbrief-egg-61061
10/28/2024, 7:17 PMyaml
courier:
templates:
verification_code:
valid:
email:
subject:
text: "Your verification code"
body:
html: "<base64://PGh0bWw+CiAgPGJvZHk+CiAgICA8aDE+WW91ciB2ZXJpZmljYXRpb24gY29kZTwvaDE+CiAgICA8cD5Zb3VyIHZlcmlmaWNhdGlvbiBjb2RlIGlzOiB7eyAuVmVyaWZpY2F0aW9uQ29kZSB9fTwvcD4KICA8L2JvZHk+CjwvaHRtbD4>="
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
The HTML content (decoded):
html
<html>
<body>
<h1>Your verification code</h1>
<p>Your verification code is: {{ .VerificationCode }}</p>
</body>
</html>
The plaintext content (decoded):
Your verification code is: {{ .VerificationCode }}
2. SMS Templates and Configuration:
For SMS verification, you'll need to set up the following template:
yaml
courier:
templates:
verification_code:
valid:
sms:
body:
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
The plaintext content (decoded):
Your verification code is: {{ .VerificationCode }}
Now, let's combine these into a single configuration file:
yaml
courier:
templates:
verification_code:
valid:
email:
subject:
text: "Your verification code"
body:
html: "<base64://PGh0bWw+CiAgPGJvZHk+CiAgICA8aDE+WW91ciB2ZXJpZmljYXRpb24gY29kZTwvaDE+CiAgICA8cD5Zb3VyIHZlcmlmaWNhdGlvbiBjb2RlIGlzOiB7eyAuVmVyaWZpY2F0aW9uQ29kZSB9fTwvcD4KICA8L2JvZHk+CjwvaHRtbD4>="
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
sms:
body:
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
selfservice:
methods:
code:
enabled: true
config:
lifespan: 15m
flows:
verification:
use: code
enabled: true
lifespan: 15m
notify_unknown_recipients: false
To apply this configuration:
1. Save this configuration to a file, e.g., updated_config.yaml
.
2. Use the Ory CLI to update your project's configuration:
ory update identity-config --project <project-id> --workspace <workspace-id> --file updated_config.yaml
This configuration sets up both email and SMS templates for verification codes, and configures the verification flow to use codes with a 15-minute lifespan [Templates](https://www.ory.sh/docs/kratos/emails-sms/sending-sms#templates) [Configuration](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#configuration).brief-egg-61061
10/28/2024, 7:17 PMyaml courier: templates: verification_code: valid: email: subject: text: "Your verification code" body: html: "<base64://PGh0bWw+CiAgPGJvZHk+CiAgICA8aDE+WW91ciB2ZXJpZmljYXRpb24gY29kZTwvaDE+CiAgICA8cD5Zb3VyIHZlcmlmaWNhdGlvbiBjb2RlIGlzOiB7eyAuVmVyaWZpY2F0aW9uQ29kZSB9fTwvcD4KICA8L2JvZHk+CjwvaHRtbD4>=" plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
The HTML content (decoded): html <html> <body> <h1>Your verification code</h1> <p>Your verification code is: {{ .VerificationCode }}</p> </body> </html>
The plaintext content (decoded): Your verification code is: {{ .VerificationCode }}
2. SMS Templates and Configuration: For SMS verification, you'll need to set up the following template: yaml courier: templates: verification_code: valid: sms: body: plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
The plaintext content (decoded): Your verification code is: {{ .VerificationCode }}
Now, let's combine these into a single configuration file: yaml courier: templates: verification_code: valid: email: subject: text: "Your verification code" body: html: "<base64://PGh0bWw+CiAgPGJvZHk+CiAgICA8aDE+WW91ciB2ZXJpZmljYXRpb24gY29kZTwvaDE+CiAgICA8cD5Zb3VyIHZlcmlmaWNhdGlvbiBjb2RlIGlzOiB7eyAuVmVyaWZpY2F0aW9uQ29kZSB9fTwvcD4KICA8L2JvZHk+CjwvaHRtbD4>=" plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>=" sms: body: plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>=" selfservice: methods: code: enabled: true config: lifespan: 15m flows: verification: use: code enabled: true lifespan: 15m notify_unknown_recipients: false
To apply this configuration: 1. Save this configuration to a file, e.g., updated_config.yaml
. 2. Use the Ory CLI to update your project's configuration: ory update identity-config --project <project-id> --workspace <workspace-id> --file updated_config.yaml
This configuration sets up both email and SMS templates for verification codes, and configures the verification flow to use codes with a 15-minute lifespan [Templates](https://www.ory.sh/docs/kratos/emails-sms/sending-sms#templates) [Configuration](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#configuration). Remember to also configure your SMTP server for email delivery and an SMS gateway for SMS delivery, as these are not included in this template configuration.