clean-piano-39737
11/11/2024, 1:37 PMbrief-egg-61061
11/11/2024, 1:37 PMbrief-egg-61061
11/11/2024, 1:38 PMory patch identity-config <your-project-id> \ --add '/selfservice/methods/code/passwordless_enabled=true'
[Enable SMS one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-sms-one-time-code-otp) 2. Select or create an identity schema that includes a phone number field: If you're using a custom schema, make sure to mark the phone number field as the identifier for the code method: json { "type": "string", "format": "tel", "title": "Phone number", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "code": { "identifier": true, "via": "sms" } } } }
[Custom identity schema](https://www.ory.sh/docs/kratos/passwordless/one-time-code#custom-identity-schema) 3. Configure an SMS channel: You need to set up an SMS provider to send the one-time codes. For testing purposes, you can use a mock SMS provider. Here's an example using the Ory CLI: ory patch identity-config --project ${project_id} \ --add '/courier/channels=[{"id":"sms","request_config":{"method":"PUT","body":"<base64://ZnVuY3Rpb24oY3R4KSB7DQpjdHg6IGN0eCwNCn0>=","url":"<https://webhook.site/#!/view/859c1c2c-c4d5-4058-aec4-53f37929c5c1>"}}]'
[Enable SMS one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-sms-one-time-code-otp) 4. (Optional) Customize the SMS template: You can customize the SMS template for the verification code: yaml courier: templates: verification_code: valid: sms: body: plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
[Templates](https://www.ory.sh/docs/kratos/emails-sms/sending-sms#templates) After completing these steps, users will be able to log in using passwordless authentication via SMS. They will enter their phone number, receive a one-time code via SMS, and then enter that code to authenticate. Remember that SMS OTP is considered less secure than other methods due to vulnerabilities like SIM swapping and SMS interception. Consider using more secure methods like Passkeys when possible. [Passwordless email & SMS](https://www.ory.sh/docs/kratos/passwordless/one-time-code)clean-piano-39737
11/11/2024, 1:38 PMbrief-egg-61061
11/11/2024, 1:39 PMbrief-egg-61061
11/11/2024, 1:39 PMkratos.yml
or similar). 2. SMS Provider: You'll need to set up your own SMS provider or service to handle the sending of SMS messages. Ory doesn't provide this service for self-hosted installations. 3. Courier Configuration: You'll need to configure the courier (the component responsible for sending messages) in your configuration file. Here's an example of how you might configure it: yaml courier: channels: - id: sms type: http request_config: url: <https://your-sms-provider-api-endpoint> method: POST body: <base64://your-base64-encoded-request-body> headers: Content-Type: application/json auth: type: api_key config: in: header name: Authorization value: your-api-key
[Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms) 4. Identity Schema: You'll still need to ensure your identity schema includes a phone number field marked as the identifier for the code method, as described in the previous answer. 5. Enable Passwordless: In your configuration file, you'll need to enable the passwordless method: yaml selfservice: methods: code: passwordless_enabled: true
[Enable email one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-email-one-time-code-otp) 6. Templates: If you want to customize the SMS templates, you'll need to add this to your configuration file as well. Remember that when self-hosting, you're responsible for ensuring the security and reliability of your SMS delivery service. You should also consider the security implications of using SMS for authentication, as it's generally considered less secure than other methods due to vulnerabilities in the SMS system. Lastly, make sure to restart your Ory Kratos instance after making these configuration changes for them to take effect.clean-piano-39737
11/11/2024, 1:48 PMCould not find a strategy to log you in with. Did you fill out the form correctly?
in response ui messages. How can I fix that?brief-egg-61061
11/11/2024, 1:48 PMbrief-egg-61061
11/11/2024, 1:49 PMpasswordless_enabled: true
for the code method in your configuration: yaml selfservice: methods: code: passwordless_enabled: true
[Enable email one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-email-one-time-code-otp) 2. Check Identity Schema: Ensure that your identity schema correctly defines the phone number field and marks it as an identifier for the code method. Your schema should include something like this: json { "type": "string", "format": "tel", "title": "Phone number", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "code": { "identifier": true, "via": "sms" } } } }
[Phone number verification](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#phone-number-verification) 3. Verify SMS Channel Configuration: Make sure you have properly configured the SMS channel in your Ory configuration. This is crucial for sending the one-time codes: yaml courier: channels: - id: sms request_config: method: PUT body: <base64://your-base64-encoded-request-body> url: <https://your-sms-provider-endpoint>
[Enable SMS one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-sms-one-time-code-otp) 4. Check Input Format: Ensure that the phone number input in your login form matches the expected format defined in your identity schema. 5. Restart Ory Kratos: After making any configuration changes, remember to restart your Ory Kratos instance for the changes to take effect. 6. Check Logs: Review your Ory Kratos logs for any additional error messages or details that might provide more insight into why the strategy isn't being found. If you've verified all these points and are still encountering the error, you may need to dig deeper into your specific setup and configuration. Consider reaching out to the Ory community or support channels with more detailed information about your configuration and the steps you've taken to reproduce the error. [Could not find a strategy to log you in with. Did you fill out the form correctly? (4010002)](https://www.ory.sh/docs/kratos/concepts/ui-user-interface#could-not-find-a-strategy-to-log-you-in-with-did-you-fill-out-the-form-correctly-4010002)clean-piano-39737
11/11/2024, 1:51 PMbrief-egg-61061
11/11/2024, 1:51 PMbrief-egg-61061
11/11/2024, 1:52 PMclean-piano-39737
11/11/2024, 2:21 PMThis account does not exist or has not setup sign in with code.
. How can I fix this?brief-egg-61061
11/11/2024, 2:21 PMbrief-egg-61061
11/11/2024, 2:22 PMjson { "type": "string", "format": "tel", "title": "Phone Number", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "code": { "identifier": true, "via": "sms" } } } }
[Passwordless one-time code login identifier](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#passwordless-one-time-code-login-identifier) 3. Enable Code Method: Make sure you have enabled the code method for authentication in your configuration: yaml selfservice: methods: code: enabled: true config: lifespan: 15m
[Configuration](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#configuration) 4. Set Up Account for Code Sign-In: If the account exists but hasn't been set up for code sign-in, you may need to update the account to enable this feature. This might involve adding the phone number to the account's traits if it's not already there. 5. Check Registration Flow: Ensure that when users register, they're providing a phone number and it's being correctly stored in their identity traits. 6. Verify Phone Number: If you require phone number verification before allowing code sign-in, make sure the phone number has been verified for the account in question. If you've checked all these points and are still encountering the error, you may need to investigate further: - Check your Ory Kratos logs for more detailed error messages. - Verify that the phone number format you're using matches what's expected by your system. - Consider temporarily enabling more verbose logging to get more insight into what's happening during the authentication attempt. Remember, this error message is specifically related to the code sign-in method, so make sure all configurations related to this method are correct. [This account does not exist or has not setup sign in with code. (4000035)](https://www.ory.sh/docs/kratos/concepts/ui-user-interface#this-account-does-not-exist-or-has-not-setup-sign-in-with-code-4000035)clean-piano-39737
11/11/2024, 2:23 PMbrief-egg-61061
11/11/2024, 2:23 PMbrief-egg-61061
11/11/2024, 2:23 PMjson { "type": "string", "format": "tel", "title": "Phone Number", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "code": { "identifier": true, "via": "sms" } } } }
[Passwordless one-time code login identifier](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#passwordless-one-time-code-login-identifier) 2. Enable Code Method: In your Ory Kratos configuration, enable the code method for both registration and login: yaml selfservice: methods: code: enabled: true config: lifespan: 15m
[Configuration](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#configuration) 3. Enable Passwordless Login: Specifically for passwordless login, you need to enable it in your configuration: yaml selfservice: methods: code: passwordless_enabled: true
[Enable email one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-email-one-time-code-otp) 4. SMS Channel Configuration: Configure the SMS channel for sending one-time codes: yaml courier: channels: - id: sms request_config: method: PUT body: <base64://your-base64-encoded-request-body> url: <https://your-sms-provider-endpoint>
[Enable SMS one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-sms-one-time-code-otp) 5. Registration Flow Configuration: Ensure that your registration flow is set up to collect and store the phone number. This typically involves configuring your registration UI to include a phone number field and ensuring that the registration API request includes the phone number in the traits. Remember to restart your Ory Kratos instance after making these configuration changes. Also, make sure that when users register, they provide a phone number that gets correctly stored in their identity traits. This is crucial for the passwordless login via SMS to work properly.clean-piano-39737
11/11/2024, 2:39 PMbrief-egg-61061
11/11/2024, 2:39 PMbrief-egg-61061
11/11/2024, 2:39 PMGET https://<your-project-slug>.<http://projects.oryapis.com/self-service/registration/browser|projects.oryapis.com/self-service/registration/browser>
This will return a response containing a flow_id
which you'll need for the next step. 2. Then, submit the registration request with the phone number: POST https://<your-project-slug>.<http://projects.oryapis.com/self-service/registration|projects.oryapis.com/self-service/registration> Content-Type: application/json { "method": "code", "traits": { "email": "<mailto:user@example.com|user@example.com>", "phone": "+1234567890" }, "flow": "<flow_id_from_previous_response>" }
Replace <your-project-slug>
with your actual project slug, and <flow_id_from_previous_response>
with the flow ID you received from the first request. Also, replace <mailto:user@example.com|user@example.com>
with the actual email and +1234567890
with the actual phone number you want to register. This request assumes that your identity schema includes both an email and a phone number field. The "method": "code"
indicates that you're using the one-time code method for registration. [Custom identity schema](https://www.ory.sh/docs/kratos/passwordless/one-time-code#custom-identity-schema) If your configuration is correct, this request should initiate the registration process and send a one-time code to the provided phone number. The response might include a message indicating that a code has been sent. Remember, the exact structure of the traits
object in your request should match your identity schema. If your schema is different, you'll need to adjust the traits
object accordingly. After this step, you would typically need to submit the received code in a separate request to complete the registration process. The exact format for submitting the code would depend on your specific setup and UI flow. [Enable SMS one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-sms-one-time-code-otp)clean-piano-39737
11/16/2024, 3:53 PM{"error":{"code":500,"status":"Internal Server Error","reason":"Expected sms template but got \u003cnil\u003e","message":"An internal server error occurred, please contact the system administrator"}}
. What do you think the problem is? And how to fix it?brief-egg-61061
11/16/2024, 3:53 PMbrief-egg-61061
11/16/2024, 3:54 PMyaml courier: templates: verification_code: valid: sms: body: plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
This base64-encoded template translates to "Your verification code is: {{ .VerificationCode }}". [Templates](https://www.ory.sh/docs/kratos/emails-sms/sending-sms#templates) 2. Verify SMS Channel Configuration: Make sure you have properly configured the SMS channel in your Ory configuration: yaml courier: channels: - id: sms request_config: method: PUT body: <base64://your-base64-encoded-request-body> url: <https://your-sms-provider-endpoint>
[Configuration](https://www.ory.sh/docs/kratos/emails-sms/sending-sms#configuration) 3. Check Courier Configuration: Ensure that the courier (the component responsible for sending messages) is properly configured in your setup. 4. Restart Ory Kratos: After making these configuration changes, restart your Ory Kratos instance for the changes to take effect. 5. Check Logs: After restarting, check your Ory Kratos logs for any additional error messages or details that might provide more insight into the issue. If you've made these changes and are still encountering the error, you may need to investigate further: - Double-check that all your configuration files are being loaded correctly. - Verify that you're using the correct version of Ory Kratos that supports the configurations you're using. - Consider reaching out to the Ory community or support channels with more detailed information about your configuration and the steps you've taken to reproduce the error. Remember, when working with self-hosted Ory solutions, it's crucial to ensure all components are properly configured and that your configuration aligns with your specific version of Ory Kratos. [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates)clean-piano-39737
11/16/2024, 4:53 PMbrief-egg-61061
11/16/2024, 4:53 PMbrief-egg-61061
11/16/2024, 4:54 PMclean-piano-39737
12/12/2024, 6:04 PMbrief-egg-61061
12/12/2024, 6:05 PMbrief-egg-61061
12/12/2024, 6:05 PMyaml courier: channels: - id: sms type: http request_config: url: <https://your-webhook-endpoint.com> method: POST
[Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms) 2. Set Up a Webhook Endpoint: Create an endpoint that can receive POST requests from Ory Kratos. This endpoint will receive the OTP code and other details. 3. Extract the Code: When Ory Kratos sends a request to your webhook endpoint, it will include the OTP code in the request body. You can extract this code from the request and use it as needed. 4. Logging (for testing purposes only): For testing, you could log the OTP code. However, be cautious with this approach and never use it in a production environment as it could expose sensitive information. yaml courier: channels: - id: sms type: http request_config: url: <https://webhook.site/your-unique-id> method: POST
[Enable SMS one-time-code (OTP)](https://www.ory.sh/docs/kratos/passwordless/one-time-code#enable-sms-one-time-code-otp) Remember, extracting the OTP code instead of sending it via SMS bypasses the security measure of delivering the code through a separate channel. This approach should only be used for testing or development purposes, never in a production environment where actual user authentication is taking place. For production use, always ensure that the OTP is delivered securely to the user through a verified channel like SMS or email. [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms)