Skip to content

fix(config)!: secure defaults, remove dead options #281

Closed

Description

@uniqueg

Problem

  • ServerConfig defaults to debug: True on host: 0.0.0.0 (template and examples too), so app.run() exposes the Werkzeug debugger.
  • enable_cors (foca/security/cors.py) calls CORS(app) with no options: * for every route, nothing configurable.
  • Dead or misleading options: access_control.api_route is documented (README, docs/access_control/README.md) but does not exist; access_control.api_controllers is never applied (the raw spec file is passed to add_api) and is overwritten in create_app; ServerConfig.environment (ignored by Flask ≥ 2.3) and use_reloader (never read); SpecConfig.path_out (only logged, plus *.modified.yaml fixtures and an OSError docstring); PymongoDirectionEnum (unused).
  • Foca.create_app fills access-control defaults by mutating the parsed config (db_name, collection_name, api_controllers are None in the model), so consumers need str(...) casts and repeated calls behave differently. DEFAULT_ACESS_CONTROL_COLLECTION_NAME is misspelled. create_app and create_celery_app duplicate setup.
  • Smaller issues: inspect.stack() called twice per factory only for a debug log; importlib.resources.path used after its context exits; _get_by_path private but imported across modules; store_enum_value misnamed; parse_custom_config splits dotted paths via Path; merge_yaml docstring says it returns None; examples/petstore/petstore_policies.conf unused.

Proposal

  • Defaults debug: False; warn at startup if debug is on with a non-loopback host; template and examples comment debug as dev-only.
  • CORSConfig: allow_origins (default ["*"]), allow_methods, allow_headers, expose_headers, allow_credentials (default False), max_age; validation error for credentials with *. Field names match Starlette's CORSMiddleware for Connexion 3.
  • Remove api_route (docs), api_controllers, environment, use_reloader, path_out, PymongoDirectionEnum and stale fixtures.
  • Non-None model defaults for db_name/collection_name; delete the mutation block in create_app; fix the constant name; share a private _create_base_app().
  • Fix the smaller issues above (importlib.resources.files, public get_by_path in foca.utils, rsplit, docstrings, drop stack inspection).

Acceptance criteria

  • Default config yields debug=False; warning test for debug on 0.0.0.0.
  • CORS options are applied (HTTP test checks Access-Control-Allow-Origin for a configured origin and for *); credentials with * fails validation.
  • Removed fields fail validation; no references remain in code, docs, template, examples.
  • create_app() called twice on one Foca instance leaves foca.conf unchanged (test).
  • Migration note lists every removed or changed key.

Breaking changes

Remove server.environment, server.use_reloader, api.specs[].path_out, security.access_control.api_controllers and api_route from configs; set debug: True explicitly for local development. Custom permissions controllers are selected via operationId in custom api_specs.

Related

Sec #6, #7; Simp #3, #4, #9; C3 2.6 (CORS part)

Activity

  1. added
    priority: high
    type flag: breaking change
    type: maintenance
    type: security
    workload: days
    on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: hightype flag: breaking changetype: maintenancetype: securityworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions