Metadata-Version: 2.1
Name: py-multiauth
Version: 1.12.0
Summary: Python package to interact with multiple authentication services
Home-page: https://escape.tech/
License: MIT
Author: Escape Technologies SAS
Author-email: ping@escape.tech
Maintainer: Antoine Carossio
Maintainer-email: antoine@escape.tech
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: Authlib (>=1.1.0,<2.0.0)
Requires-Dist: PyJWT (>=2.6.0,<3.0.0)
Requires-Dist: graphql-core (>=3.2.3,<4.0.0)
Requires-Dist: jsonschema (>=4.17.3,<5.0.0)
Requires-Dist: pycognito (>=2022.11.2,<2023.0.0)
Requires-Dist: pydash (>=5.1.2,<6.0.0)
Project-URL: Bug Tracker, https://github.com/Escape-Technologies/py-multiauth/issues
Project-URL: Repository, https://github.com/Escape-Technologies/py-multiauth
Description-Content-Type: text/markdown

# py-multiauth ![PyPI](https://img.shields.io/pypi/v/py-multiauth) [![CI](https://github.com/Escape-Technologies/py-multiauth/actions/workflows/ci.yaml/badge.svg)](https://github.com/Escape-Technologies/py-multiauth/actions/workflows/ci.yaml) [![CD](https://github.com/Escape-Technologies/py-multiauth/actions/workflows/cd.yaml/badge.svg)](https://github.com/Escape-Technologies/py-multiauth/actions/workflows/cd.yaml) [![codecov](https://codecov.io/gh/Escape-Technologies/py-multiauth/branch/main/graph/badge.svg?token=NL148MNKAE)](https://codecov.io/gh/Escape-Technologies/py-multiauth)

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py-multiauth)
![PyPI - Downloads](https://img.shields.io/pypi/dm/py-multiauth)

## Installation

```bash
pip install py-multiauth
```

## Supported methods

|Name     |Authenticate|Refresh|Extra    |
|---------|:----------:|:-----:|---------|
|`API_KEY`|✓           |       |         |
|`AWS`    |✓           |✓      |Signature|
|`BASIC`  |✓           |       |         |
|`REST`   |✓           |✓      |         |
|`DIGEST` |✓           |       |         |
|`GRAPHQL`|✓           |       |         |
|`HAWK`   |✓           |       |         |
|`MANUAL` |✓           |       |         |
|`OAUTH`  |✓           |✓      |         |

## Usage

### Loading a configuration file

Currently, we support 4 way of loading a configuration file.

```python

# Using constructor argument
MultiAuth(authrc_file='path.json')

# Using environment variable
os.environ['AUTHRC'] = 'path.json'

# Using autodection
os.paths.exists('.authrc')?

# Using autodection from user home directory
os.path.exists(os.path.expanduser('~/.multiauth/.authrc'))?
```

### Managing authentication flow

**MultiAuth supports context singleton.
From that, you can instanciate MultiAuth and re-use the same class in another package as far it is sharing the same context.**

```python
auth = MultiAuth(auths=.., users=.., authrc=.., logger=..)

# Sending the requests to get the correct headers
auth.authenticate_users()

# Getting the header before sending a HTTP request
auth_headers = auth.reauthenticate(username=.., additional_headers=.., no_auth=..)
r = requests.get('https://example.com', headers=auth_headers[0])
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License ![PyPI - License](https://img.shields.io/pypi/l/py-multiauth)

[MIT](https://choosealicense.com/licenses/mit/)

