> ## 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.

# OidcSecurity

Manage OIDC security on the session.

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> table = session.create_table(
...     "Restrictions example",
...     data_types={"Country": "String"},
... )
>>> session.tables.restrictions.update(
...     {
...         "ROLE_FRANCE": table["Country"] == "France",
...         "ROLE_UK": table["Country"] == "UK",
...     }
... )
```

Roles from the authentication provider’s ID Token can be mapped to roles in the session:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> session.security.oidc.role_mapping.update(
...     {"atoti user": {"ROLE_USER"}, "France": {"ROLE_FRANCE"}}
... )
>>> session.security.oidc.role_mapping
{'France': frozenset({'ROLE_FRANCE'}), 'atoti user': frozenset({'ROLE_USER'})}
```

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

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

Note that the name claim is required in the access token to identify the user for any client application.

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> session.security.oidc.role_mapping.clear()
>>> session.security.oidc.role_mapping
{}
```

### Members

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