password method is the most commonly used form of authentication, it
identifier (username, email, phone number, ...) and a
during registration and login.
ORY Kratos hashes the password after registration, password reset, and password change using the Argon2 Hashing Algorithm, the winner of the (https://github.com/P-H-C/phc-winner-argon2)[Password Hashing Competition (PHC)].
Enabling this method is as easy as setting
in your ORY Kratos configuration. You can configure the Argon2 hasher using the following options:
When a user signs up using this strategy, the Default Identity JSON Schema (set
identity.default_schema_url) is used:
If you don't know what that means, please read the Identity Data Model Chapter in the docs' concepts section.
For a complete reference, defaults, and description please check the Configuration Reference.
For a better understanding of security implications imposed by Argon2 Configuration, head over to Argon2 Security.
Choosing between Username, Email, Phone Number
Before you start, you need to decide what data you want to collect from your users and why! It is hard to change this decision afterwards, so make sure you've taken everything into account!
When logging in, the user will use a login identifier and a password to sign up and in. The identifier can be
- a username - e.g. "john.doe" or "johndoe123" or "oryuser",
- an email address - e.g.
- a phone number - e.g.
All of these approaches have up- and downsides.
Using the email address as the login identifier is easy to remember, does not require additional fields (because the email address is already being collected), and is usually unique. It's usually unique because sometimes companies use a "shared" email account (e.g. firstname.lastname@example.org) to access services. In that case, multiple real identities are using the same email identifier to log in.
The email address however represents a unique identifier and personally
identifiable information (PII). An attacker could for example check if an email
email@example.com) is registered at a site (e.g. an adult
website) and use that information for blackmail (see
Account Enumeration Attacks).
The same considerations apply to using a phone number as the primary registration & login identifier.
Using a free text username reduces the privacy risk because it is much harder to make a connection between the username and a real world identity. It's still possible in cases where users choose a username such as "john.doe.from.newyork.1970", but finding the right username identifier is still difficult and there is plausible deniability because anyone could use that username.
A free text username however requires capturing additional fields (e.g. an email
address for password resets / account recovery) and is hard to remember. It is
often very difficult to find unique usernames as people tend to use a
combination of their names and initials (e.g.
john.doe) which has a high
chance of collision. Therefore, one ends up with usernames such as
It is important to understand that ORY Kratos lowercases all
identifiers and therefore E-Mail addresses. Characters
. which have
special meaning for some E-Mail Providers (e.g. GMail) are not normalized:
userNAMEis equal to
foo@BaR.comis equal to
firstname.lastname@example.org NOT equal to
email@example.com NOT equal to
You need to decide which route you want to take.
Picking the right Identity JSON Schema
When processing an identity and its traits, the method will use JSON Schema to extract one or more identifiers.
Use Case: Email and Password
To use the email address as the login identifier, define the following Identity JSON Schema:
Use Case: Multiple E-Mails and Password
You can allow users to sign up with multiple E-Mail Addresses and use any of those for log in:
Use Case: Username and Password
To use a username as the login identifier, define the following Identity JSON Schema:
Use Case: Username and Email and Password
You may also mix usernames and passwords:
Use Case: Phone Number And Password
This will be addressed in a future release and is tracked as kratos#137.
Assuming your Identity JSON Schema is as follows:
And an identity registers with the following JSON payload (more on registration in Selfservice Registration):
password method would generate a credentials block as follows:
Because credential identifiers need to be unique, no other identity can be
created that has
firstname.lastname@example.org as their