Commit Graph
40 Commits
Author SHA1 Message Date
GareArc 64fcd9859f fix: move exempt prefixes to module-level constant and refactor license status caching
- Move console_exempt_prefixes to module-level _CONSOLE_EXEMPT_PREFIXES
  to avoid per-request tuple construction in before_request handler
- Refactor get_cached_license_status into focused helper methods
  (_read_cached_license_status, _fetch_and_cache_license_status) to
  reduce try/except nesting
- Add exc_info=True to debug-level exception logs for diagnosability
- Add LicenseStatus return type annotation with TYPE_CHECKING guard
2026-03-11 14:08:12 -07:00
GareArc 6625828246 fix: exempt setup flow endpoints from license check
Add /console/api/init and /console/api/login to the license exempt
list so that fresh installs can complete setup when the enterprise
license is inactive. Without these exemptions the init password
validation and post-setup auto-login are blocked, causing the setup
page to enter an infinite reload loop.
2026-03-08 23:45:10 -07:00
GareArc 9a682f1009 fix: use LicenseStatus enum instead of raw strings and tighten path prefix matching
Replace raw license status strings with LicenseStatus enum values in
app_factory.py and enterprise_service.py to prevent silent mismatches.
Use trailing-slash prefixes ('/console/api/', '/api/') to avoid false
matches on unrelated paths like /api-docs.
2026-03-05 01:16:45 -08:00
GareArc 757fabda1e fix: exempt console bootstrap APIs from license check to prevent infinite reload loop 2026-03-04 22:13:25 -08:00
GareArc 858ccd8746 feat: add Redis caching for enterprise license status
Cache license status for 10 minutes to reduce HTTP calls to enterprise API.
Only caches license status, not full system features.

Changes:
- Add EnterpriseService.get_cached_license_status() method
- Cache key: enterprise:license:status
- TTL: 600 seconds (10 minutes)
- Graceful degradation: falls back to API call if Redis fails

Performance improvement:
- Before: HTTP call (~50-200ms) on every API request
- After: Redis lookup (~1ms) on cached requests
- Reduces load on enterprise service by ~99%
2026-03-04 21:28:11 -08:00
GareArc ea35ee0a3e feat: extend license enforcement to webapp API endpoints
Extend license middleware to also block webapp API (/api/*) when
enterprise license is expired/inactive/lost.

Changes:
- Check both /console/api and /api endpoints
- Add webapp-specific exempt paths:
  - /api/passport (webapp authentication)
  - /api/login, /api/logout, /api/oauth
  - /api/forgot-password
  - /api/system-features (webapp needs this to check license status)

This ensures both console users and webapp users are blocked when
license expires, maintaining consistent enforcement across all APIs.
2026-03-04 20:38:03 -08:00
GareArc 0e9dc86f3b fix: use UnauthorizedAndForceLogout to trigger frontend logout on license expiry
Change license check to raise UnauthorizedAndForceLogout exception instead
of returning generic JSON response. This ensures proper frontend handling:

Frontend behavior (service/base.ts line 588):
- Checks if code === 'unauthorized_and_force_logout'
- Executes globalThis.location.reload()
- Forces user logout and redirect to login page
- Login page displays license expiration UI (already exists)

Response format:
- HTTP 401 (not 403)
- code: "unauthorized_and_force_logout"
- Triggers frontend reload which clears auth state

This completes the license enforcement flow:
1. Backend blocks all business APIs when license expires
2. Backend returns proper error code to trigger logout
3. Frontend reloads and redirects to login
4. Login page shows license expiration message
2026-03-04 20:30:53 -08:00
GareArc 0ed39d81e9 feat: add global license check middleware to block API access on expiry
Add before_request middleware that validates enterprise license status
for all /console/api endpoints when ENTERPRISE_ENABLED is true.

Behavior:
- Checks license status before each console API request
- Returns 403 with clear error message when license is expired/inactive/lost
- Exempts auth endpoints (login, oauth, forgot-password, etc.)
- Exempts /console/api/features so frontend can fetch license status
- Gracefully handles errors to avoid service disruption

This ensures all business APIs are blocked when license expires,
addressing the issue where APIs remained callable after expiry.
2026-03-04 20:10:42 -08:00
GareArc 7ef139cadd Squash merge 1.12.1-otel-ee into release/e-1.12.1 2026-03-04 16:59:37 -08:00
盐粒 YanliGitHubautofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
5bf0251554 chore(typing): reduce ty excludes for A1 (#31721)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-30 02:38:57 +08:00
Asuka MinatoGitHubgemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
8d45755303 feat: init fastopenapi (#30453)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-23 21:07:52 +09:00
wangxiaoleiandGitHub 3b225c01da refactor: refactor workflow context (#30607) 2026-01-19 12:18:51 +08:00
Byron.wangandGitHub 5362f69083 feat(refactoring): Support Structured Logging (JSON) (#30170) 2026-01-04 11:46:46 +08:00
fanadongGitHubhieheiheiautofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>-LAN-
44f8915e30 feat: Add Aliyun SLS (Simple Log Service) integration for workflow execution logging (#28986)
Co-authored-by: hieheihei <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: -LAN- <[email protected]>
2025-12-17 13:43:54 +08:00
wangxiaoleiandGitHub 094f417b32 refactor: admin api using session factory (#29628) 2025-12-15 12:01:41 +08:00
wangxiaoleiandGitHub f48522e923 feat: add x-trace-id to http responses and logs (#29015)
Introduce trace id to http responses and logs to facilitate debugging process.
2025-12-02 17:22:34 +08:00
wangxiaoleiandGitHub d162f7e5ef feat(api): automatically NODE_TYPE_CLASSES_MAPPING generation from node class definitions (#28525) 2025-12-01 14:14:19 +08:00
Asuka MinatoGitHubgemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
3cf19dc07f add two test examples (#28236)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-21 10:36:41 +08:00
-LAN-GitHubautofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
a2e0f80c01 [Chore/Refactor] Improve type checking configuration (#25185)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-05 08:34:18 +08:00
Asuka MinatoandGitHub 3032e6fe59 example for logging (#24441) 2025-08-25 11:41:17 +08:00
-LAN-andGitHub e340fccafb feat: integrate flask-orjson for improved JSON serialization performance (#23935) 2025-08-14 19:50:59 +08:00
Asuka MinatoandGitHub a189d293f8 make logging not use f-str, change others to f-str (#22882) 2025-07-25 10:32:48 +08:00
6a74c97a0a feat: add debug log for request and response (#19781) (#19783)
Co-authored-by: hashjang <[email protected]>
Co-authored-by: QuantumGhost <[email protected]>
2025-05-17 17:31:09 +08:00
湛露先生andGitHub 505d4cce78 Revert "sort extensions for review," (#19496) 2025-05-11 16:57:13 +08:00
湛露先生andGitHub c431da9571 sort extensions for review, (#19470)
Signed-off-by: zhanluxianshen <[email protected]>
2025-05-10 20:01:31 +08:00
-LAN-andGitHub f23cf98317 refactor: Remove RepositoryFactory (#19176)
Signed-off-by: -LAN- <[email protected]>
2025-05-06 21:14:51 +08:00
AichiB7AandGitHub 8299614e60 [Observability][Bugfix] Fix expected an instance of Token, got None error in OpenTelemetry (#18934) 2025-04-28 10:31:13 +08:00
-LAN-andGitHub 61e39bccdf fix: Patch OpenTelemetry to handle None tokens (#18498)
Signed-off-by: -LAN- <[email protected]>
2025-04-22 16:04:20 +08:00
-LAN-andGitHub 6d9dd3109e feat: add a abstract layer for WorkflowNodeExcetion (#18026) 2025-04-17 12:48:52 +09:00
AichiB7AandGitHub 5f8d20b5b2 [Observability] Integrate OpenTelemetry (#17627) 2025-04-11 17:04:06 +08:00
YeuolyandGitHub 490b6d092e Fix/plugin race condition (#14253) 2025-02-25 12:20:47 +08:00
-LAN-andGitHub 99f40a9682 feat: full support for opendal and sync configurations between .env and docker-compose (#11754)
Signed-off-by: -LAN- <[email protected]>
2024-12-18 09:05:54 +08:00
-LAN-andGitHub e86756cb39 feat(app_factory): speed up api startup (#11762)
Signed-off-by: -LAN- <[email protected]>
2024-12-18 09:05:31 +08:00
9b46b02717 refactor: assembling the app features in modular way (#9129)
Signed-off-by: -LAN- <[email protected]>
Co-authored-by: -LAN- <[email protected]>
2024-11-30 23:05:22 +08:00
Jinzhou ZhangandGitHub 6f418da388 Fixes #11065: tenant_id not found when login via ADMIN_KEY (#11066) 2024-11-27 19:50:56 +08:00
Bowen LiangandGitHub 0e8ab0588f fix: (#10437 followup) fix conditions with DEBUG config (#10438) 2024-11-08 09:42:53 +08:00
Bowen LiangandGitHub 0ebe198ff1 chore: use DEBUG in dify_config instead of parsing raw system environment variable in place (#10437) 2024-11-08 09:34:11 +08:00
Bowen LiangandGitHub 4d9160ca9f refactor: use dify_config to replace legacy usage of flask app's config (#9089) 2024-10-22 11:01:32 +08:00
zhuhaoandGitHub 83b2b8fe60 refactor: add logging extension module for log initialization (#9524) 2024-10-22 09:00:44 +08:00
Sergio SacristánandGitHub 28de676956 controller test (#9469) 2024-10-18 08:23:36 +08:00