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

# atoti.security.basic_authentication_security.BasicAuthenticationSecurity.credentials

#### *property* BasicAuthenticationSecurity.credentials *: [MutableMapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [str](https://docs.python.org/3/library/stdtypes.html#str)]*

Mapping from username to password.

Use [`individual_roles`](./atoti.security.Security.individual_roles#atoti.security.Security.individual_roles) to grant roles to the users.

### Example

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> session_config = tt.SessionConfig(security=tt.SecurityConfig())
>>> session = tt.Session.start(session_config)
>>> session.security.basic_authentication.credentials
{}
```

Letting a user authenticate through Basic Authentication requires two steps:

* Granting the required role:
  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> session.security.individual_roles["Chen"] = {"ROLE_USER"}
  ```
* Configuring credentials:
  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> session.security.basic_authentication.credentials["Chen"] = "Peking"
  ```

The password can be changed:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> session.security.basic_authentication.credentials["Chen"] = "Beijing"
```

But, for security reasons, it cannot be retrieved.
Accessing it will return a redacted string:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> session.security.basic_authentication.credentials
{'Chen': '**REDACTED**'}
```

Revoking access:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> del session.security.basic_authentication.credentials["Chen"]
>>> session.security.basic_authentication.credentials
{}
```

Cleaning the individual roles to not leave unused keys:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> del session.security.individual_roles["Chen"]
```
