rs_server_common package

Subpackages

Submodules

rs_server_common.authentication module

Authentication functions implementation.

Note: calls https://gitlab.si.c-s.fr/space_applications/eoservices/apikey-manager

async rs_server_common.authentication.apikey_security(request: Request, apikey_header: str) tuple[list, dict, str]

FastAPI Security dependency for the cluster mode. Check the api key validity, passed as an HTTP header.

Parameters:

apikey_header (Security) – API key passed in HTTP header

Returns:

Tuple of (IAM roles, config) information from the keycloak server, associated with the api key.

rs_server_common.authentication.apikey_validator(station, access_type)

Decorator to validate API key access.

Parameters:
  • station (str) – The station name = adgs or cadip

  • access_type (str) – The type of access.

Raises:

HTTPException – If the authorization key does not include the right role to access the specified station.

Returns:

Decorator function.

Return type:

function

rs_server_common.fastapi_app module

Init the FastAPI application.

async rs_server_common.fastapi_app.health() HealthSchema

Always return a flag set to ‘true’ when the service is up and running.

Otherwise this code won’t be run anyway and the caller will have other sorts of errors.

async rs_server_common.fastapi_app.home()

Home endpoint.

rs_server_common.fastapi_app.init_app(api_version: str, routers: list[APIRouter], init_db: bool = True, pause: int = 3, timeout: int = None, startup_events: list[Callable] = None, shutdown_events: list[Callable] = None)

Init the FastAPI application. See: https://praciano.com.br/fastapi-and-async-sqlalchemy-20-with-pytest-done-right.html

Parameters:
  • api_version (str) – version of our application (not the version of the OpenAPI specification

  • used) (nor the version of FastAPI being)

  • routers (list[APIRouter]) – list of FastAPI routers to add to the application.

  • init_db (bool) – should we init the database session ?

  • timeout (int) – timeout in seconds to wait for the database connection.

  • pause (int) – pause in seconds to wait for the database connection.

  • startup_events (list[Callable]) – list of functions that should be run before the application starts

  • shutdown_events (list[Callable]) – list of functions that should be run when the application is shutting down

rs_server_common.settings module

Store diverse objects and values used throughout the application.

async rs_server_common.settings.del_http_client()

Close and delete HTTP client.

rs_server_common.settings.env_bool(var: str, default: bool) bool

Return True if an environemnt variable is set to 1, true or yes (case insensitive). Return False if set to 0, false or no (case insensitive). Return the default value if not set or set to a different value.

rs_server_common.settings.http_client()

Get HTTP client

rs_server_common.settings.set_http_client(value)

Set HTTP client

Module contents

Main package of commons of rs-server services.