5.2. Realms

Users need to be in realms to have tokens assigned. A user who is not a member of a realm cannot have a token assigned and cannot authenticate.

You can combine several different UserIdResolvers (see User ID Resolvers) into a realm. The system knows one default realm. Users within this default realm can authenticate with their username.

Users in realms that are not the default realm need to be additionally identified. Therefore, the users need to authenticate with their username and the realm like this:

user@realm

5.2.1. Users and Realms in a request

When a request is processed, the given parameters are evaluated and a user object is created within the request. If the user object cannot be created, a User Error E904 is returned.

However, privacyIDEA can modify the given user related parameters and modify the user object.

You can use the policy set_realm in the scope authentication if you want to set the realm to a specific value. It is evaluated before the parameters are evaluated to a user object.

The other possibilities change the user after the user object has been initially created from the given parameters:

You can use the policy mangle in the scope authentication if you want to set the realm, the username or even the password. In this case you can use regular expressions to modify these values, and the user object is created again from the modified values.

The pre event handler RequestMangler Handler Module can modify user parameters in the request as well. The user object is only created again from the modified parameters if its option reset_user is checked.

The policy setrealm from the scope authorization sets the realm of the user object.

5.2.2. Relate User to a Realm

There are several options to relate a user to a specific realm during authentication. Usually, if only a login name is given, the user will be searched in the default realm, indicated with defrealm in the mapping table below.

If a realm parameter is given in a /auth or /validate/check request, it supersedes a possible split realm.

The following table shows different combinations of user(name)-parameter and realm-parameter. Depending on the Use @ sign to split the username and the realm.-setting, the following table shows in which realm the user will be searched.

Input parameter

Use @ sign to split the username and the realm.-setting

user(name)

realm

true

false

user

–

user ➔ defrealm

user ➔ defrealm

user

realm1

user ➔ realm1

user ➔ realm1

user

unknown

–

–

user@realm1

–

user ➔ realm1

user@realm1 ➔ defrealm

user@realm1

realm1

user ➔ realm1

user@realm1 ➔ realm1

user@realm1

realm2

user ➔ realm2

user@realm1 ➔ realm2

user@realm2

realm1

user ➔ realm1

user@realm2 ➔ realm1

user@realm1

unknown

–

–

user@unknown

–

user@unknown ➔ defrealm

user@unknown ➔ defrealm

user@unknown

realm1

user@unknown ➔ realm1

user@unknown ➔ realm1

user@unknown

unknown

–

–

Note

Be aware that if the Use @ sign to split the username and the realm.-setting is true, a realm parameter is given and a user name with an @-sign is given where the part after the @ denotes a valid realm, the realm parameter will take precedence.

5.2.3. List of Realms

The realm list at Users -> Realms shows the already defined realms.

It shows the name of the realms, whether it is the default realm and the names of the resolvers that are combined to this realm.

If multiple nodes exist, you can display the realms for each node by selecting the node from the Node drop-down menu. By default all nodes are selected. The resolvers of each node are displayed below the node name. The resolvers in the realm that are not assigned to a node are displayed under All nodes.

../_images/realm_list_all.png

Realm list of all nodes

Selecting a specific node lists only the realms that have at least one resolver assigned to that node; for these realms all resolvers are still shown, grouped by All nodes and by node. A realm that only has resolvers under All nodes is not listed for the node, although the node uses it: a node uses the resolvers under All nodes together with the resolvers assigned to it.

A node lists and manages the tokens of the users it serves: the tokens whose owner belongs to a resolver the node uses in a realm, and the tokens without an owner. The tokens of users that only other nodes serve are left out. A token whose owner belongs to a resolver that is in no realm at all, e.g. because the resolver was deleted, belongs to no node and is listed on every node, so that it can still be found and deleted. The token janitor finds such tokens as orphaned, see Cleanup Jobs.

You can delete or edit an existing realm or create a new realm.

5.2.4. Create Realm

A new realm can be created directly in the realm list, in the row below the existing realms.

Each realm has to have a unique name. The name of the realm is case insensitive. If you create a new realm with the same name as an existing realm, the existing realm gets overwritten.

Select the resolvers of the realm. Optionally, a priority can be set for each resolver. A realm without resolvers can be created as well, but it contains no users.

If multiple nodes exist, you can select the resolvers and their priorities separately for each node. The resolvers selected under All nodes are not node specific, and these settings will be applied to all nodes.

../_images/realm_create_list.png

Create a realm on the list page

5.2.5. Edit Realm

In the realm list, the edit button of a realm switches its row to edit mode. The resolvers and priorities can be selected in place, for each node separately. A realm can contain several resolvers. The save button stores the changes.

../_images/realm_edit_list.png

Edit a realm directly in the realm list

5.2.6. Resolver Priority

Within a realm you can give each resolver a priority. The priority determines the order in which resolvers are searched when looking up a user. If a user with the same login name exists in more than one resolver, the user will be taken from the resolver with the lowest priority number (i.e. the highest priority).

If a resolver fails to answer the lookup, for example because its user store is not reachable or returns an error, the lookup stops with an error. The resolvers with a lower priority are not asked, as they could hold another user with the same login name.

Priorities are numbers between 1 and 999. The lower the number the higher the priority. If no priority is set, the resolver defaults to priority 1000.

If two resolvers share the same priority, they are ordered alphabetically by resolver name. To avoid ambiguity, it is recommended to assign a distinct priority to each resolver.

Note

A resolver has a priority per realm. I.e. the same resolver can have a different priority in each realm it belongs to.

5.2.6.1. User Masking

When a realm contains multiple resolvers, the resolver priority determines which users are visible. If a user with the same login name exists in more than one resolver, only the user from the highest-priority resolver is visible. The user in the lower-priority resolver is masked (hidden).

This affects:

  • Authentication: The user always authenticates against the highest-priority resolver.

  • User list: The user list (in the WebUI and via the API) only shows the user from the highest-priority resolver. The duplicate in the lower-priority resolver is suppressed.

  • Policies: By default, policies only match the resolver where the user was found (the highest-priority one). See Check all possible resolvers of a user to also match the lower-priority resolvers that contain the user.

Example:

A user “administrator” is located in a resolver “users” which contains all Active Directory users. And the “administrator” is located in a resolver “admins”, which contains all users in the Security Group “Domain Admins” from the very same domain. Both resolvers are in the realm “AD”, “admins” with priority 1 and “users” with priority 2.

The user “administrator@AD” will always resolve to the user in resolver “admins”. The duplicate entry in “users” is masked and will not appear in the user list. This is useful to create separate policies for members of the security group “Domain Admins”.

5.2.7. Creating the First Realm

If you have a fresh installation, no resolver and no realm is defined. The previous WebUI asked at each administrator login whether it should automatically create a first realm named defrealm with a resolver deflocal containing all users from /etc/passwd.

The current WebUI does not offer this anymore, since in most modern deployments (e.g. containers) /etc/passwd only contains system accounts that are of no use for enrolling tokens. In addition, the automatically created realm defrealm became the default realm, so authentication requests without a realm were resolved against the local system accounts, which often caused surprising results.

Instead, a dialog appears at each administrator login as long as no realm exists and the administrator is allowed to create resolvers. If no resolver exists either, the dialog tells the administrator to create a resolver first, because a resolver is the source of the users, and offers a button Create resolver that leads directly to the resolver creation. If a resolver already exists, the dialog explains that a realm is needed to enroll tokens for users and offers a button Create realm that leads to the realm management. The button Later closes the dialog without any action. Nothing is created automatically. Create your first resolver and realm pointing to your actual user store (e.g. LDAP, Active Directory or SQL) in the WebUI under Users.

If you still want a realm based on /etc/passwd for a quick start or demo setup, you can create it on the command line:

echo '{"fileName": "/etc/passwd"}' > deflocal.conf
pi-manage config resolver create deflocal passwdresolver deflocal.conf
pi-manage config realm create defrealm deflocal

Note

The first realm you create will be the default realm. So if you create another realm later and want this new realm to be the default realm, you need to set this new realm to be default manually.