Skip to content

Directory

Defines an external directory for account authentication and lookups.

This object can be configured from the WebUI under Settings › Authentication › Directories

Directory is a multi-variant object: each instance has an @type discriminator selecting one of the variants below, and each variant carries its own set of fields.

LDAP Directory

Type: String · required

Short description of this directory

Type: Uri · default: "ldap://localhost:389"

URL of the LDAP server

Type: Duration · default: "30s"

Connection timeout to the server

Type: Boolean · default: false

Allow invalid TLS certificates when connecting to the server

Type: Boolean · default: false

Use TLS to connect to the remote server

Type: String · required

The base distinguished name (DN) from where searches should begin

Type: String?

The distinguished name of the account that the server will bind as to connect to the LDAP directory

Type: SecretKeyOptional · required

The password or secret for the bind DN account

Type: Boolean · default: true

Whether to use bind authentication. When enabled, the server will use the filterLogin to search for the user account and then attempt to bind as that account using the provided password. When disabled, the server will use the bind DN and secret to connect to the LDAP server and obtain the secret from the account entry using the attrSecret attribute.

Type: String · default: "(&(objectClass=inetOrgPerson)(mail=?))"

Searches for user accounts by e-mail address during authentication

Type: String · default: "(|(&(objectClass=inetOrgPerson)(|(mail=?)(mailAlias=?)))(&(objectClass=groupOfNames)(|(mail=?)(mailAlias=?))))"

Searches for users or groups matching a recipient e-mail address or alias

Type: String? · default: "(&(objectClass=groupOfNames)(member=?))"

Searches for groups that an account is member of. Use when the group membership is not provided in the account entry. The ? in the filter will be replaced with the account DN.

Type: String[] · default: ["objectClass"]

LDAP attribute for the user’s account type, if missing defaults to individual.

Type: String[] · default: ["description"]

LDAP attributes used to store the user’s description

Type: String[] · default: ["mail"]

LDAP attribute for the user’s primary email address

Type: String[] · default: ["mailAlias"]

LDAP attribute for the user’s email alias(es)

Type: String[] · default: ["memberOf"]

LDAP attributes for the groups that a user belongs to. Used when filterMemberOf is not configured or when the group membership is also provided in the account entry.

Type: String[] · default: ["userPassword"]

LDAP attribute for the user’s password hash. This setting is required when binding as a service user. When using bind authentication, configure the secret-changed attribute instead.

Type: String[] · default: ["pwdChangeTime"]

LDAP attribute that provides a password change hash or a timestamp indicating when the password was last changed. When using bind authentication, this attribute is used to determine when to invalidate OAuth tokens.

Type: String · default: "groupOfNames"

LDAP object class used to identify group entries

Type: UnsignedInt · default: 10 · max: 8192

Maximum number of connections that can be maintained simultaneously in the connection pool

Type: Duration · default: "30s"

Maximum amount of time that the connection pool will wait for a new connection to be created

Type: Duration · default: "30s"

Maximum amount of time that the connection pool manager will wait for a connection to be recycled

Type: Duration · default: "30s"

Maximum amount of time that the connection pool will wait for a connection to become available

Type: Id<Tenant>? · enterprise

Identifier for the tenant this directory belongs to

SQL Database

Type: String · required

Short description of this directory

Type: SqlAuthStore · required

Storage backend where accounts and groups are stored

Type: String · default: "name"

Column name for e-mail address. Optional, you can use instead a query to obtain the account’s addresses.

Type: String · default: "secret"

Column name for the account password.

Type: String? · default: "type"

Column name for account type

Type: String? · default: "description"

Column name for account full name or description

Type: String · default: "SELECT name, secret, description, type FROM accounts WHERE name = $1"

Query to obtain the account details by login e-mail address.

Type: String · default: "SELECT name, secret, description, type FROM accounts WHERE name = $1 AND active = true"

Query to obtain the account details by recipient e-mail address or alias.

Type: String? · default: "SELECT member_of FROM group_members WHERE name = $1"

Query to obtain the groups an account is member of.

Type: String? · default: "SELECT address FROM emails WHERE name = $1"

Query to obtain the e-mail aliases of an account.

Type: Id<Tenant>? · enterprise

Identifier for the tenant this directory belongs to

OpenID Connect

Type: String · required

Short description of this directory

Type: Uri · required

The base URL of the OpenID Connect provider (e.g. https://sso.example.com/realms/myrealm). Stalwart will use this URL to automatically discover the provider’s endpoints, including the token validation and user info endpoints.

Type: String? · default: "stalwart"

If set, Stalwart will reject any token whose aud (audience) claim does not include this value. Set this to the client ID or resource identifier registered for Stalwart in your identity provider to ensure tokens issued for other applications are not accepted.

Type: String[] · default: ["openid","email"]

If set, Stalwart will reject any token that does not include all of the specified scopes. Useful for ensuring that only tokens explicitly granted access to the mail server are accepted.

Type: String · default: "preferred_username"

The claim name used to retrieve the user’s login name from the token or user info response. Common values are preferred_username, email, or sub depending on your provider’s configuration. If the claim value is not an email address and usernameDomain is set, the domain will be appended automatically (e.g. john becomes [email protected]). If the claim value already contains an @, it is used as-is. If the claim value is not an email address and no usernameDomain is configured, Stalwart will fall back to the email claim. If neither yields a valid email address, authentication will be rejected.

Type: String?

The domain name to append to the username when the value of claimUsername does not contain an @ symbol (e.g. setting this to example.com will turn john into [email protected]). If not set, Stalwart will fall back to the email claim when the username claim does not contain a valid email address.

Type: String? · default: "name"

The claim name used to retrieve the user’s display name from the token or user info response. Common values are name or display_name. If not set, the display name will not be populated.

Type: String?

The claim name used to retrieve the user’s group memberships from the token or user info response. Common values are groups or roles depending on your provider’s configuration. If not set, group information will not be populated. Note that some providers omit group claims from the token to keep its size small and only return them via the user info endpoint, if group information is missing, ensure your provider is configured to include it.

Type: Id<Tenant>? · enterprise

Identifier for the tenant this directory belongs to

The Directory object is available via the urn:stalwart:jmap capability.

This is a standard Foo/get method as defined in RFC 8620, Section 5.1.

This method requires the sysDirectoryGet permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Directory/get",
{
"ids": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This is a standard Foo/set method as defined in RFC 8620, Section 5.3.

Supports create, update, and destroy operations in a single call.

This operation requires the sysDirectoryCreate permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Directory/set",
{
"create": {
"new1": {
"@type": "Ldap",
"baseDn": "Example",
"bindSecret": {
"@type": "None"
},
"description": "Example"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This operation requires the sysDirectoryUpdate permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Directory/set",
{
"update": {
"id1": {
"description": "updated value"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This operation requires the sysDirectoryDestroy permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Directory/set",
{
"destroy": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This is a standard Foo/query method as defined in RFC 8620, Section 5.5.

This method requires the sysDirectoryQuery permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:Directory/query",
{
"filter": {
"memberTenantId": "id1"
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

The x:Directory/query filter argument accepts the following conditions (combinable with AnyOf / AllOf / Not per RFC 8620):

ConditionKind
memberTenantIdid of Tenant

stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.

Terminal window
stalwart-cli get Directory id1
Terminal window
stalwart-cli create Directory/Ldap \
--field description=Example \
--field baseDn=Example \
--field 'bindSecret={"@type":"None"}'
Terminal window
stalwart-cli query Directory
stalwart-cli query Directory --where memberTenantId=id1
Terminal window
stalwart-cli update Directory id1 --field description='updated value'
Terminal window
stalwart-cli delete Directory --ids id1

An optional secret value, or none.

  • None: No secret. No additional fields.
  • Value: Secret value. Carries the fields of SecretKeyValue.
  • EnvironmentVariable: Secret read from environment variable. Carries the fields of SecretKeyEnvironmentVariable.
  • File: Secret read from file. Carries the fields of SecretKeyFile.

A secret value provided directly.

Type: String · required · secret

Password or secret value

A secret value read from an environment variable.

Type: String · required

Environment variable name to read the secret from

A secret value read from a file.

Type: String · required

File path to read the secret from

Defines the SQL database used to store account and group information for SQL directories.

  • Default: Use data store (SQL only). No additional fields.
  • PostgreSql: PostgreSQL. Carries the fields of PostgreSqlStore.
  • MySql: mySQL. Carries the fields of MySqlStore.
  • Sqlite: SQLite. Carries the fields of SqliteStore.

PostgreSQL data store.

Type: Duration? · default: "15s"

Connection timeout to the database

Type: Boolean · default: false

Use TLS to connect to the store

Type: Boolean · default: false

Allow invalid TLS certificates when connecting to the store

Type: UnsignedInt? · default: 10 · max: 8192 · min: 1

Maximum number of connections to the store

Type: PostgreSqlRecyclingMethod · default: "fast"

Method to use when recycling connections in the pool

Type: PostgreSqlSettings[] · enterprise

List of read replicas for the store

Type: String · required

Hostname of the database server

Type: UnsignedInt · default: 5432 · max: 65535 · min: 1

Port of the database server

Type: String · default: "stalwart"

Name of the database

Type: String? · default: "stalwart"

Username to connect to the store

Type: SecretKeyOptional · required

Password to connect to the store

Type: String?

Additional connection options

PostgreSQL connection settings.

Type: String · required

Hostname of the database server

Type: UnsignedInt · default: 5432 · max: 65535 · min: 1

Port of the database server

Type: String · default: "stalwart"

Name of the database

Type: String? · default: "stalwart"

Username to connect to the store

Type: SecretKeyOptional · required

Password to connect to the store

Type: String?

Additional connection options

MySQL data store.

Type: Duration? · default: "15s"

Connection timeout to the database

Type: Boolean · default: false

Use TLS to connect to the store

Type: Boolean · default: false

Allow invalid TLS certificates when connecting to the store

Type: UnsignedInt? · max: 1073741824 · min: 1024

Maximum size of a packet in bytes

Type: UnsignedInt? · default: 10 · max: 8192 · min: 1

Maximum number of connections to the store

Type: UnsignedInt? · default: 5 · max: 8192 · min: 1

Minimum number of connections to the store

Type: MySqlSettings[] · enterprise

List of read replicas for the store

Type: String · required

Hostname of the database server

Type: UnsignedInt · default: 3306 · max: 65535 · min: 1

Port of the database server

Type: String · default: "stalwart"

Name of the database

Type: String? · default: "stalwart"

Username to connect to the store

Type: SecretKeyOptional · required

Password to connect to the store

MySQL connection settings.

Type: String · required

Hostname of the database server

Type: UnsignedInt · default: 3306 · max: 65535 · min: 1

Port of the database server

Type: String · default: "stalwart"

Name of the database

Type: String? · default: "stalwart"

Username to connect to the store

Type: SecretKeyOptional · required

Password to connect to the store

SQLite embedded data store.

Type: String · required

Path to the SQLite data directory

Type: UnsignedInt? · max: 64 · min: 1

Number of worker threads to use for the store, defaults to the number of cores

Type: UnsignedInt · default: 10 · max: 8192 · min: 1

Maximum number of connections to the store

ValueLabel
fastFast recycling method
verifiedVerified recycling method
cleanClean recycling method