Skip to main content

Authentication & authorization helpers for eoAPI

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eoapi_auth_utils-0.4.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eoapi_auth_utils-0.4.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file eoapi_auth_utils-0.4.1.tar.gz.

File metadata

  • Download URL: eoapi_auth_utils-0.4.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for eoapi_auth_utils-0.4.1.tar.gz
Algorithm Hash digest
SHA256 7f3bf341268013340acf004b4a0b81e74b61b89e90cc9c12a9113446433b21d7
MD5 3872db4e79beaa75585a8cefee9c0854
BLAKE2b-256 a1f64650a5e59a305396ceb5e5aa176a19eee8687ee37efab276bf485c428873

See more details on using hashes here.

Provenance

The following attestation bundles were made for eoapi_auth_utils-0.4.1.tar.gz:

Publisher: publish.yaml on developmentseed/eoapi-auth-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eoapi_auth_utils-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for eoapi_auth_utils-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 137ec0d298e67eb82af0d5a1d8bdb125cd367e83c153cc76e0762c9c066b5309
MD5 10a3b9e275ff4e488e7497fef1272888
BLAKE2b-256 ca51187e684d6040df6ed3eb7785ce73efd7b7cc532d1fd179cf6b5c15c665c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for eoapi_auth_utils-0.4.1-py3-none-any.whl:

Publisher: publish.yaml on developmentseed/eoapi-auth-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page