Skip to main content

Connexion Auth Paths Extended

Small connexion extension to add authentication into spec routes

The connexion framework it's possible to use a parameter called auth_all_paths (in FlaskApp and AioHttpApp), which in your documentation (link) is defined as:

:param auth_all_paths: whether to authenticate not defined paths
:type auth_all_paths: bool

And it can be used this way, during app initialization:

from connexion import FlaskApp # or AioHttpApp


connexion_app = FlaskApp(
    __name__,
    specification_dir='swagger/',
    auth_all_paths=True
)

But the only routes added to the authentication are the 404 Error route (link) routes, but there are other routes that should also be treated:

  • /openapi.json
  • /openapi.yaml
  • openapi_spec_path

The idea of this extension is to apply the default authentication on these routes, without changing the behavior of anything else.

Why?

This was once a requirement requested by the security team in an internal project. The API documentation provides very detailed technical information for the attackers external world, sometimes including email addresses, internal application’s url, API’s structure, and other stuffs. Think that specification it’s like a map, It's also very helpful for them to dig for vulnerabilities and detect targets.

What about the SwaggerUI (/ui/) route?

It is not necessary, as it does not make much sense to ask for a auth/token on a page that will be accessed by the browser. And if some kind of authentication is required, it must be provided to consume the routes through the interface.

Installation

Install with pip:

  pip install connexion-auth-paths-extd

or

  pip install connexion-auth-paths-extd[aiohttp]

Usage/Examples

from connexion.extended.auth_paths_extd import FlaskApp # or AioHttpApp


connexion_app = FlaskApp(
    __name__,
    specification_dir='swagger/',
    auth_all_paths=True
)

Almost the same, we just change where we are importing the FlaskApp class from. The auth_paths_extd.FlaskApp object works exactly the same as connexion.FlaskApp, same methods, attributes and initialization. No extra parameters are needed, just pass auth_all_paths as True.

No dependencies are required in addition to the connexion itself.

A better exemple is on examples folder.

Metadata

Release files for connexion-auth-paths-extd 0.0.6

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

Source distribution (sdist)

Source distribution for connexion-auth-paths-extd 0.0.6
File Size Uploaded Provenance Actions
connexion_auth_paths_extd-0.0.6.tar.gz 6.1 kB Without provenance Details for connexion_auth_paths_extd-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for connexion-auth-paths-extd 0.0.6
File Interpreter ABI Platform Actions
connexion_auth_paths_extd-0.0.6-py3-none-any.whl Python 3 none any Details for connexion_auth_paths_extd-0.0.6-py3-none-any.whl

Total release size: 12.6 kB

Release files / connexion_auth_paths_extd-0.0.6.tar.gz

Download URL connexion_auth_paths_extd-0.0.6.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
319b84ca773c05d5ae9a296172d92004b4f4bf1c1fc7c9893d742cc927d7aa03
BLAKE2b-256 checksum
How to use checksums
46bc1117fdf18be8cf5f7bad036edd0fa457fd9285e352d19d96e49b2c03c895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

Release files / connexion_auth_paths_extd-0.0.6-py3-none-any.whl

Download URL connexion_auth_paths_extd-0.0.6-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
706b262fb38245dcfe40719c6fa2b8d38526a2782cbd9b66bd63a35199385179
BLAKE2b-256 checksum
How to use checksums
74e64e4990eb227a990b558efc3f41f0d549cda938c0fee6f7a000c24b03a4a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

Security for connexion-auth-paths-extd 0.0.6

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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