Metadata-Version: 2.1
Name: aserto-idp
Version: 0.2.1
Summary: Common identity providers for use with Aserto client libraries
Home-page: https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/aserto-idp
License: Apache-2.0
Author: Aserto, Inc.
Author-email: pypi@aserto.com
Maintainer: authereal
Maintainer-email: authereal@aserto.com
Requires-Python: >=3.7,<4.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Dist: aiohttp (>=3.8.1,<4.0.0)
Requires-Dist: python-jose[cryptography] (>=3.3.0,<4.0.0)
Requires-Dist: typing-extensions (>=3.10.0,<4.0.0)
Project-URL: Documentation, https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/aserto-idp
Project-URL: Repository, https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/aserto-idp
Description-Content-Type: text/markdown

# Aserto Identity Providers
Common identity providers for use with Aserto client libraries

## Installation
### Using Pip
```sh
pip install aserto-idp
```
### Using Poetry
```sh
poetry add aserto-idp
```
## Current Identity Providers
### Auth0
```py
from aserto_idp.auth0 import generate_oauth_subject_from_auth_header
```
### Stay tuned for more!
## Usage
### With [`aserto-authorizer-grpc`](https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/aserto-authorizer-grpc)
```py
from aserto_authorizer_grpc.aserto.api.v1 import IdentityContext, IdentityType
from aserto_idp.auth0 import AccessTokenError, generate_oauth_subject_from_auth_header


try:
    subject = await generate_oauth_subject_from_auth_header(
        authorization_header=request.headers["Authorization"],
        domain=AUTH0_DOMAIN,
        client_id=AUTH0_CLIENT_ID,
        audience=AUTH0_AUDIENCE,
    )

    identity_context = IdentityContext(
        type=IdentityType.IDENTITY_TYPE_SUB,
        identity=subject,
    )
except AccessTokenError:
    identity_context = IdentityContext(type=IdentityType.IDENTITY_TYPE_NONE)

```
### With [`aserto`](https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/aserto)
```py
from aserto import Identity
from aserto_idp.auth0 import AccessTokenError, generate_oauth_subject_from_auth_header


try:
    subject = await generate_oauth_subject_from_auth_header(
        authorization_header=request.headers["Authorization"],
        domain=AUTH0_DOMAIN,
        client_id=AUTH0_CLIENT_ID,
        audience=AUTH0_AUDIENCE,
    )

    identity = Identity(type="SUBJECT", subject=subject)
except AccessTokenError:
    identity = Identity(type="NONE")
```
