narrow-hospital-35452
01/14/2025, 10:55 AMbrief-egg-61061
01/14/2025, 10:55 AMbrief-egg-61061
01/14/2025, 10:56 AM{
"id": 4000007,
"text": "An account with the same identifier (email, phone, username, ...) exists already.",
"type": "error"
}
This error is now consistently returned when attempting to register with an identifier (in your case, a phone number) that already exists in the system. The change you've noticed is actually a correction of behavior. Allowing registration with a phone number that's already associated with another account could lead to security issues and identity conflicts. It's worth noting that Ory regularly improves its software, and these improvements sometimes include tightening security measures. As stated in the [Ory Ecosystem Upgrade Guide](https://www.ory.sh/docs/ecosystem/upgrading): > Good software improves over time. If it wouldn't, you shouldn't use it. Unfortunately, some of these improvements have breaking changes. If you need to update a user's phone number or link multiple identities, you should look into using the appropriate flows for updating user information or linking accounts, rather than attempting to register a new account with an existing identifier. For the most up-to-date information on changes between versions, always refer to the changelog and upgrade guide for Kratos when upgrading to a new version.narrow-hospital-35452
01/14/2025, 11:00 AMTo set a phone number as unique across users in Ory Kratos, you need to modify the identity schema. However, it's important to note that making phone numbers unique can potentially lead to security issues and is generally not recommended. Here's why:
1. Uniqueness constraints on phone numbers can enable account enumeration attacks, as mentioned in the Ory documentation on emails and phone numbers.
2. Phone numbers, like email addresses, should be verified before being trusted or used as unique identifiers. The documentation states: "Never trust unverified email addresses and phone numbers."
3. There are potential issues with reserving phone numbers even if they're not verified, as discussed in a GitHub issue about phone number verification.
so, what is the best practice?brief-egg-61061
01/14/2025, 11:00 AMbrief-egg-61061
01/14/2025, 11:00 AMjson { "type": "string", "format": "tel", "title": "Phone number", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true } }, "verification": { "via": "sms" } } }
This configuration allows the phone number to be used as an identifier and enables verification via SMS. To address the security concerns: 1. Account Enumeration: While uniqueness can potentially enable account enumeration, Kratos has built-in protections against this. The error messages for existing accounts are designed to be vague to mitigate this risk. 2. Verification: Kratos provides flows for verifying phone numbers before they're used as trusted identifiers. This helps prevent abuse and ensures the phone number is actually owned by the user. 3. Reservation of Unverified Numbers: Kratos now handles this more securely. Unverified phone numbers are associated with accounts but not trusted until verified. In conclusion, the best practice is to use phone numbers as unique identifiers, but always in conjunction with proper verification. The changes in newer versions of Kratos (like 1.3.1) reflect these best practices by enforcing uniqueness and providing robust verification flows. For the most up-to-date and detailed information, always refer to the [official Ory documentation](https://www.ory.sh/docs/kratos/) and consider joining the [Ory Community Slack](https://slack.ory.sh/) for specific questions and the latest best practices.