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

# BasicAuthenticationSecurity.credentials

> *getter* BasicAuthenticationSecurity.credentials: [MutableMapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)\[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/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.

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
>>> 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/6.2/languages/pycon.tmLanguage.json"]}}
  >>> session.security.individual_roles["Chen"] = {"ROLE_USER"}
  ```
* Configuring credentials:
  ```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
  >>> session.security.basic_authentication.credentials["Chen"] = "Peking"
  ```

The password can be changed:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/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/6.2/languages/pycon.tmLanguage.json"]}}
>>> session.security.basic_authentication.credentials
{'Chen': <redacted>}
```

Revoking access:

```pycon theme={"languages":{"custom":["/engine/python-sdk/6.2/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/6.2/languages/pycon.tmLanguage.json"]}}
>>> del session.security.individual_roles["Chen"]
>>> session.security.individual_roles
{}
```
