Skip to content

fix: require api_token for /token endpoint when configured#1795

Closed
Br1an67 wants to merge 1 commit intounclecode:developfrom
Br1an67:fix/issue-1627-token-auth
Closed

fix: require api_token for /token endpoint when configured#1795
Br1an67 wants to merge 1 commit intounclecode:developfrom
Br1an67:fix/issue-1627-token-auth

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

Summary

Fixes #1627

The /token endpoint issues JWT tokens to anyone with a valid email domain, with no credential check. This adds an api_token field to the security config. When set, the /token endpoint requires the caller to provide the matching api_token in the request body before issuing a JWT.

Existing deployments without api_token configured are unaffected (backward compatible).

List of files changed and why

  • deploy/docker/auth.py — Added optional api_token field to TokenRequest
  • deploy/docker/server.py — Validate api_token against config before issuing JWT
  • deploy/docker/config.yml — Added api_token field under security section

How Has This Been Tested?

Verified logic: when security.api_token is empty (default), the endpoint works as before. When set, requests without a matching api_token get a 401 response.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Add api_token field to security config and TokenRequest. When
security.api_token is set in config.yml, the /token endpoint validates
the provided api_token before issuing a JWT. Existing deployments without
api_token configured are unaffected (backward compatible).

Closes unclecode#1627
unclecode added a commit that referenced this pull request Mar 7, 2026
…1734, #1290, #1668)

Bug fixes:
- Verify redirect targets are alive before returning from URL seeder (#1622)
- Wire mean_delay/max_range from CrawlerRunConfig into dispatcher rate limiter (#1786)
- Use DOMParser instead of innerHTML in process_iframes to prevent XSS (#1796)

Security/Docker:
- Require api_token for /token endpoint when configured (#1795)
- Deep-crawl streaming now mirrors Python library behavior via arun() (#1798)

CI:
- Bump GitHub Actions to latest versions - checkout v6, setup-python v6,
  build-push-action v6, setup-buildx v4, login v4 (#1734)

Features:
- Support type-list pipeline in JsonCssExtractionStrategy for chained
  extraction like ["attribute", "regex"] (#1290)
- Add --json-ensure-ascii CLI flag and JSON_ENSURE_ASCII config setting
  for Unicode preservation in JSON output (#1668)
@unclecode unclecode changed the base branch from main to develop March 7, 2026 08:45
@unclecode
Copy link
Owner

Thanks @Br1an67 - this is a solid security hardening for the Docker deployment. We've merged it into develop and it will be in the next release. We'll acknowledge your contribution.

@unclecode unclecode closed this Mar 7, 2026
unclecode added a commit that referenced this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: endpoint /token does not require credentials

2 participants