> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LdapSecurity

Manage LDAP security on the session.

> [!NOTE]
>
> This requires [`atoti.SecurityConfig.main_sso`](./atoti.config.security.SecurityConfig#atoti.SecurityConfig.main_sso) to be an instance of [`LdapConfig`](./atoti.config.security.LdapConfig#atoti.LdapConfig).

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> table = session.create_table(
...     "Restrictions example",
...     data_types={"City": "String"},
... )
>>> session.tables.restrictions["ROLE_MATHS"] = table["City"] == "Paris"
```

Roles from the authentication provider can be mapped to roles in the session:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> session.security.ldap.role_mapping["MATHEMATICIANS"] = {
...     "ROLE_MATHS",
...     "ROLE_USER",
... }
>>> sorted(session.security.ldap.role_mapping["MATHEMATICIANS"])
['ROLE_MATHS', 'ROLE_USER']
```

Default roles can be given to users who have no individual or mapped roles granted:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> session.security.ldap.default_roles.add("ROLE_USER")
>>> session.security.ldap.default_roles
{'ROLE_USER'}
```

### Members

| Name | Summary |
| - | - |
| [`default_roles`](./atoti.security.LdapSecurity.default_roles#atoti.security.ldap_security.LdapSecurity.default_roles) | |
| [`role_mapping`](./atoti.security.LdapSecurity.role_mapping#atoti.security.ldap_security.LdapSecurity.role_mapping) | The role mapping is done with the roles included in the ID Token sent by the authentication provider. |
