Skip to main content

eoAPI Auth Utils

Helpers for authentication & authorization patterns for eoAPI applications.

PyPI - Version

Usage

Installation

pip install eoapi.auth-utils

Integration

In your eoAPI application:

from eoapi.auth_utils import AuthSettings, OpenIdConnectAuth
from fastapi import FastAPI
from fastapi.routing import APIRoute
from stac_fastapi.api.app import StacApi

auth_settings = AuthSettings(_env_prefix="AUTH_")

api = StacApi(
    app=FastAPI(
        # ...
        swagger_ui_init_oauth={
            "clientId": auth_settings.client_id,
            "usePkceWithAuthorizationCodeGrant": auth_settings.use_pkce,
        },
    ),
    # ...
)

if auth_settings.openid_configuration_url:
    oidc_auth = OpenIdConnectAuth.from_settings(auth_settings)

    # Implement your custom app-specific auth logic here...
    restricted_routes = {
        "/collections": ("POST", "stac:collection:create"),
        "/collections/{collection_id}": ("PUT", "stac:collection:update"),
        "/collections/{collection_id}": ("DELETE", "stac:collection:delete"),
        "/collections/{collection_id}/items": ("POST", "stac:item:create"),
        "/collections/{collection_id}/items/{item_id}": ("PUT", "stac:item:update"),
        "/collections/{collection_id}/items/{item_id}": ("DELETE", "stac:item:delete"),
    }
    api_routes = {
        route.path: route for route in api.app.routes if isinstance(route, APIRoute)
    }
    for endpoint, (method, scope) in restricted_routes.items():
        route = api_routes.get(endpoint)
        if route and method in route.methods:
            oidc_auth.apply_auth_dependencies(route, required_token_scopes=[scope])

Development

Releases

Releases are managed via CICD workflow, as described in the Python Packaging User Guide. To create a new release:

  1. Update the version in eoapi/auth_utils/__init__.py following appropriate Semantic Versioning convention.
  2. Push a tagged commit to main, with the tag matching the package's new version number.

[!NOTE]
This package makes use of Github's automatically generated release notes. These can be later augmented if one sees fit.

Release files for eoapi-auth-utils 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eoapi-auth-utils 0.4.1
File Size Uploaded
eoapi_auth_utils-0.4.1.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eoapi-auth-utils 0.4.1
File Interpreter ABI Platform
eoapi_auth_utils-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / eoapi_auth_utils-0.4.1.tar.gz

Download URL eoapi_auth_utils-0.4.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7f3bf341268013340acf004b4a0b81e74b61b89e90cc9c12a9113446433b21d7
BLAKE2b-256 checksum
How to use checksums
a1f64650a5e59a305396ceb5e5aa176a19eee8687ee37efab276bf485c428873
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2024.

Transparency log

Release files / eoapi_auth_utils-0.4.1-py3-none-any.whl

Download URL eoapi_auth_utils-0.4.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
137ec0d298e67eb82af0d5a1d8bdb125cd367e83c153cc76e0762c9c066b5309
BLAKE2b-256 checksum
How to use checksums
ca51187e684d6040df6ed3eb7785ce73efd7b7cc532d1fd179cf6b5c15c665c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page