clean-piano-39737
12/26/2024, 11:54 AM{
"$schema": "<http://json-schema.org/draft-07/schema#>",
"title": "Phone-Schema-v0",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"phone": {
"type": "string",
"format": "tel",
"title": "Phone Number",
"<http://ory.sh/kratos|ory.sh/kratos>": {
"credentials": {
"code": {
"identifier": true,
"via": "sms"
}
},
"verification": {
"via": "sms"
}
}
}
}
}
}
}
My kratos config is as follows (I tried adding templates wherever I can):
...
selfservice:
...
methods:
...
code:
enabled: true
passwordless_enabled: true
template: test
templates:
sms:
body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgImNoYW5uZWwiOiAic21zIiwKICAicHJpb3JpdHk>iOiAxLAogICJyZWNpcGllbnRfbGlzdCI6IGN0eC5yZWNpcGllbnQsCiAgInRlbXBsYXRlX2lkIjogIjU5ZGVlMzZkLWQ4NDEtNDE1ZS1hMjkzLTAwYzE2NjljMDY1NSIsCiAgInRlbXBsYXRlX3BhcmFtZXRlcnMiOiB7CiAgICAiY29kZSI6IGN0eC50ZW1wbGF0ZV9kYXRhLlZlcmlmaWNhdGlvbkNvZGUKICB9Cn0=
config:
type: sms
sms:
send_otp_url: "https://<my-sms--sending-service>/send"
template: test
otp:
expiry: 600
flows:
...
registration:
lifespan: 10m
ui_url: <http://localhost:4455/registration>
after:
...
code:
hooks:
- hook: session
- hook: show_verification_ui
identity:
default_schema_id: "phone_schema_v0"
schemas:
- id: email_schema_v0
url: file:///etc/config/kratos/identity.email_schema_v0.json
- id: phone_schema_v0
url: file:///etc/config/kratos/identity.phone_schema_v0.json
courier:
templates:
verification_code:
valid:
email:
body:
plaintext: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgImNoYW5uZWwiOiAic21zIiwKICAicHJpb3JpdHk>iOiAxLAogICJyZWNpcGllbnRfbGlzdCI6IGN0eC5yZWNpcGllbnQsCiAgInRlbXBsYXRlX2lkIjogIjU5ZGVlMzZkLWQ4NDEtNDE1ZS1hMjkzLTAwYzE2NjljMDY1NSIsCiAgInRlbXBsYXRlX3BhcmFtZXRlcnMiOiB7CiAgICAiY29kZSI6IGN0eC50ZW1wbGF0ZV9kYXRhLlZlcmlmaWNhdGlvbkNvZGUKICB9Cn0=
sms:
body:
plaintext: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgImNoYW5uZWwiOiAic21zIiwKICAicHJpb3JpdHk>iOiAxLAogICJyZWNpcGllbnRfbGlzdCI6IGN0eC5yZWNpcGllbnQsCiAgInRlbXBsYXRlX2lkIjogIjU5ZGVlMzZkLWQ4NDEtNDE1ZS1hMjkzLTAwYzE2NjljMDY1NSIsCiAgInRlbXBsYXRlX3BhcmFtZXRlcnMiOiB7CiAgICAiY29kZSI6IGN0eC50ZW1wbGF0ZV9kYXRhLlZlcmlmaWNhdGlvbkNvZGUKICB9Cn0=
smtp:
connection_uri: <smtp://smtp:1025>
sms:
request_config:
url: https://<my-sms-sending-service>/send
method: POST
body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgImNoYW5uZWwiOiAic21zIiwKICAicHJpb3JpdHk>iOiAxLAogICJyZWNpcGllbnRfbGlzdCI6IGN0eC5yZWNpcGllbnQsCiAgInRlbXBsYXRlX2lkIjogIjU5ZGVlMzZkLWQ4NDEtNDE1ZS1hMjkzLTAwYzE2NjljMDY1NSIsCiAgInRlbXBsYXRlX3BhcmFtZXRlcnMiOiB7CiAgICAiY29kZSI6IGN0eC50ZW1wbGF0ZV9kYXRhLlZlcmlmaWNhdGlvbkNvZGUKICB9Cn0=
headers:
Content-Type: application/json
auth:
type: api_key
config:
name: Authorization
value: Basic <my-token>
in: header
# type: basic_auth
# config:
# user: <my-client-id>
# password: <my-client-secret>
But when I try to send this registration request:
curl --location '<http://localhost:4455/.ory/kratos/public/self-service/registration?flow=4aafa73b-7163-40d5-98af-6fdf8ea94645>' --header 'Content-Type: application/json' --header 'Accept: application/json' --data-raw '{"method": "code","traits": {"phone": "+201234567890"}}'
I get the following response:
{
"error": {
"code": 500,
"status": "Internal Server Error",
"reason": "Expected sms template but got <nil>",
"message": "An internal server error occurred, please contact the system administrator"
}
}
What do you think?clean-piano-39737
12/26/2024, 1:16 PMmost-train-86113
12/27/2024, 8:19 AMregistration_code
in courier/templates
clean-piano-39737
12/28/2024, 7:02 PMregistration_code
is not a valid field in my courier/templates
config.
If it's valid in your config, which Kratos version are you using? I'm currently using oryd/kratos:v1.2.0
.colossal-airline-19852
01/15/2025, 6:17 PMcourier:
smtp:
connection_uri: <smtps://test:test@mailslurper:1025/?skip_ssl_verify=true>
channels:
- id: sms
type: http
request_config:
url: <https://url_to_sms/sms/send>
method: "POST"
headers: {}
body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgVG86IGN0eC5yZWNpcGllbnQsCiAgQm9keTogY3R>4LmJvZHksCn0=
templates:
verification_code:
valid:
email:
body:
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGU>gfX0="
sms:
body:
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGU>gfX0="
login_code:
valid:
email:
body:
plaintext: "<base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19>"
sms:
body:
plaintext: "<base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19>"
try this courier
config @clean-piano-39737, this worked for me.
(please modify base64 content according your needs)clean-piano-39737
01/19/2025, 10:38 AM