busy-agent-70196
03/16/2025, 10:17 AMbrief-egg-61061
03/16/2025, 10:17 AMbrief-egg-61061
03/16/2025, 10:17 AMjson { "$id": "<https://schemas.ory.sh/presets/kratos/identity.email.schema.json>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "title": "E-Mail", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "code": { "identifier": true, "via": "email" } } }, "maxLength": 320 } }, "required": ["email"], "additionalProperties": false } } }
## 2. Enable the code method in your configuration Update your Kratos configuration file (kratos.yml) to enable the code method: yaml selfservice: methods: code: enabled: true passwordless_enabled: true # Enable this for passwordless login config: lifespan: 15m # Defines how long the code is valid for
## 3. Configure SMTP for email delivery Set up your SMTP connection to send the one-time codes: yaml courier: smtp: connection_uri: <smtps://username:password@smtp-server:1234/>
## 4. Configure the login flow (optional) If you want to use identifier-first authentication (where users enter their email first, then get a code): yaml selfservice: flows: login: style: identifier_first
## 5. Restart Ory Kratos After making these configuration changes, restart your Ory Kratos instance to apply them. These steps will enable Email OTP functionality in your self-hosted Ory Kratos instance. Users will be able to authenticate using one-time codes sent to their email addresses. Sources: [Passwordless one-time code login identifier](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#passwordless-one-time-code-login-identifier) [Email and SMS one-time-code authentication](https://www.ory.sh/docs/kratos/passwordless/one-time-code) [Identifier first authentication](https://www.ory.sh/docs/identities/sign-in/identifier-first-authentication)busy-agent-70196
03/17/2025, 7:40 AMbrief-egg-61061
03/17/2025, 7:40 AMbrief-egg-61061
03/17/2025, 7:40 AMconnection_uri
is a configuration parameter used to specify the connection details for the SMTP server that will be used to send emails. This is particularly important for features like email verification, account recovery, and one-time password (OTP) authentication. The connection_uri
follows a URL-like format that includes: - Protocol (smtp or smtps) - Username and password - Server address - Port number - Optional parameters For example: <smtp://username:password@server:port/>
It's important to note that the username and password must be [URI encoded](https://en.wikipedia.org/wiki/Percent-encoding) to properly handle special characters. Different security mechanisms can be specified in the `connection_uri`: 1. StartTLS with certificate verification (recommended): <smtp://username:password@server:port/>
2. StartTLS without certificate verification: <smtp://username:password@server:port/?skip_ssl_verify=true>
3. Cleartext SMTP (not secure, for development only): <smtp://username:password@server:port/?disable_starttls=true>
4. Implicit TLS with certificate verification: <smtps://username:password@server:port/>
5. Other variations with different security options When configuring your self-hosted Ory Kratos for email delivery, you would include this in your configuration file: yaml courier: smtp: connection_uri: <smtp://username:password@server:port/> from_address: <mailto:noreply@yourdomain.com|noreply@yourdomain.com> from_name: Your Company Name
[Use a custom server to send Ory Identity messages to users](https://www.ory.sh/docs/kratos/emails-sms/sending-emails-smtp) provides more detailed information about configuring SMTP for Ory Kratos.busy-agent-70196
03/17/2025, 8:10 AMbrief-egg-61061
03/17/2025, 8:10 AMbrief-egg-61061
03/17/2025, 8:10 AM