iatoolkit 2.81.16__tar.gz → 2.83.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {iatoolkit-2.81.16/src/iatoolkit.egg-info → iatoolkit-2.83.1}/PKG-INFO +1 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/__init__.py +1 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/cli_commands.py +1 -0
- iatoolkit-2.83.1/src/iatoolkit/common/csrf_guard.py +139 -0
- iatoolkit-2.83.1/src/iatoolkit/common/rate_limiter.py +111 -0
- iatoolkit-2.83.1/src/iatoolkit/common/security_headers.py +125 -0
- iatoolkit-2.83.1/src/iatoolkit/common/user_errors.py +34 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/core.py +53 -2
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/locales/en.yaml +7 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/locales/es.yaml +8 -2
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/api_key_repo.py +9 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/models.py +18 -5
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/profile_repo.py +7 -3
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/api_key_service.py +13 -3
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/auth_service.py +70 -9
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/jwt_service.py +31 -2
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/profile_service.py +86 -22
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/change_password_view.py +3 -2
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/chat_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/conversations_api_view.py +3 -2
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/forgot_password_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/help_content_api_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/home_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/init_context_api_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/login_view.py +8 -4
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/signup_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/verify_user_view.py +2 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1/src/iatoolkit.egg-info}/PKG-INFO +1 -1
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit.egg-info/SOURCES.txt +4 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/LICENSE +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/LICENSE_COMMUNITY.md +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/pyproject.toml +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/readme.md +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/setup.cfg +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/base_company.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/access.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/bridge_validation.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/company_paths.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/decision_types.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/exceptions.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/asset_storage.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/database_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/history_compaction_trigger.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/memory_compilation_trigger.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/secret_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/signup_policy_resolver.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/interfaces/web_search_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/memory_tools.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/model_registry.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/routes.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/search_terms.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/secret_resolver.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/session_manager.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/text_splitter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/url_safety.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/common/util.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/company_registry.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/llm_capabilities.yaml +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/conversation_title.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/history_compaction.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/memory_compiler.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/memory_correction.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/memory_document_ingest.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/memory_image_ingest.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/memory_meeting_ingest.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents/memory_question_review.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_agents_pack.yaml +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/channel_business_identity.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/channel_conversation_continuity.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/channel_response_style.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/chart_output.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/chat_state_rules.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/chat_user_profile.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/core_identity.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/email_output.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/file_download_output.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/html_structures.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/links_documents.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/memory_usage.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/multimodal_basics.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/output_basics.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/presentation_formatting.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_aggregation_scope.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_casting.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_core.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_jsonb.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_mysql_casting.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_mysql_json.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_redshift_basics.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/sql_redshift_types.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts/tool_html_passthrough.prompt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_prompts_pack.yaml +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/config/system_tools_pack.yaml +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/brevo_mail_app.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/call_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/file_connector.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/file_connector_factory.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/google_cloud_storage_connector.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/google_drive_connector.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/local_file_connector.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/connectors/s3_connector.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/google_auth_client.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/google_chat_app.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/inference_embeddings_client.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/inference_handler.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/jina_embeddings_client.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_gateway_resolver.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/anthropic_adapter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/attachment_mime.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/deepseek_adapter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/gemini_adapter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/openai_adapter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/openai_compatible_chat_adapter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_providers/openrouter_adapter.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_proxy.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/llm_response.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/openrouter_decision_client.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/infra/redis_session_manager.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/advisory_lock.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/bridge_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/conversation_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/database_manager.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/document_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/env_secret_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/filesystem_asset_repository.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/knowledge_wiki_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/llm_query_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/mcp_token_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/memory_question_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/memory_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/memory_usage_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/prompt_resource_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/sql_dataset_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/sql_source_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/repositories/vs_repo.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/runtime_logging.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/attachment_policy_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/branding_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/chart_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/chat_stream.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/company_context_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/configuration_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/context_builder_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/conversation_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/decision_attachments.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/decision_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/dispatcher_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/embedding_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/excel_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/file_processor_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/history_compaction_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/history_manager_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/http_tool_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/i18n_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/inference_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/knowledge_base_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/language_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/license_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/llm_client_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/mail_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/markdown_wiki_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/mcp_token_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_compiler_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_lookup_policy_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_question_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_sources.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_usage_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/memory_wiki_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/noop_history_compaction_trigger.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/noop_memory_compilation_trigger.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/operator_identity_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/contracts.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/image_normalizer.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/parsing_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/pdf_ocr_detection.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/provider_factory.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/provider_resolver.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/providers/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/providers/basic_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/providers/docling_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/parsers/validator.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/pdf_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/prompt_resource_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/prompt_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/query_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/resource_access_scope.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/signup_guard_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/signup_policy_resolver.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/sql_catalog_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/sql_dataset_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/sql_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/sql_source_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/storage_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/structured_output_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/system_agent_catalog.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/system_agent_runner.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/system_prompt_catalog.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/system_tools.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/telemetry_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/tenant_wiki_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/tool_output_contract.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/tool_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/user_feedback_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/user_session_context_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/visual_kb_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/visual_tool_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/warmup_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/web_search/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/web_search/provider_factory.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/web_search/providers/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/web_search/providers/brave_provider.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/web_search_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/services/wiki_page_index_service.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/images/favicon.ico +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/images/favicon.png +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/images/fernando.jpeg +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/images/iatoolkit_core.png +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/images/iatoolkit_logo.png +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_charts.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_conversations.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_feedback_button.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_filepond.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_header_navigation.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_help_content.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_logout_button.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_main.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_memory_button.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_model_selector.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_onboarding_button.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_prompt_manager.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/js/chat_stream.js +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/account.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/chat_iatoolkit.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/chat_modal.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/chat_public.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/documents.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/landing_page.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/llm_output.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/onboarding.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/static/styles/wiki_page.css +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/_chat_header.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/_company_header.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/_login_widget.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/account.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/base.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/change_password.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/chat.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/chat_memory_modal.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/chat_modals.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/error.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/forgot_password.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/home_hosted_default.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/invitation_invalid.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/login_global.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/memory/wiki_schema.md +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/pdf/base.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/pdf/letter.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/pdf/report.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/pdf/simple.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/signup.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/templates/wiki_page.html +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/__init__.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/account_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/api_key_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/base_login_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/categories_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/chat_context_preview_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/configuration_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/connectors_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/embedding_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/llmquery_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/llmquery_stream_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/load_document_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/logout_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/memory_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/profile_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/prompt_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/prompt_context_preview_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/prompt_resource_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/rag_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/root_redirect_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/static_page_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/tool_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/user_feedback_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/users_api_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit/views/wiki_page_view.py +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit.egg-info/dependency_links.txt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit.egg-info/requires.txt +0 -0
- {iatoolkit-2.81.16 → iatoolkit-2.83.1}/src/iatoolkit.egg-info/top_level.txt +0 -0
|
@@ -28,6 +28,7 @@ def register_core_commands(app):
|
|
|
28
28
|
else:
|
|
29
29
|
click.echo("✅ ¡Api-key is ready! add this variable to your environment:")
|
|
30
30
|
click.echo(f"IATOOLKIT_API_KEY='{result['api-key']}'")
|
|
31
|
+
click.echo("⚠️ Copy it now: only its hash is stored, it will not be shown again.")
|
|
31
32
|
except Exception as e:
|
|
32
33
|
logging.exception(e)
|
|
33
34
|
click.echo(f"❌ unexpectd error during the configuration: {e}")
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Copyright (c) 2024 Fernando Libedinsky
|
|
2
|
+
# Product: IAToolkit
|
|
3
|
+
#
|
|
4
|
+
# IAToolkit is open source software.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Cross-site request forgery guard (BL-030, PR-8).
|
|
8
|
+
|
|
9
|
+
A request that changes something (POST, PUT, PATCH, DELETE), carries the session
|
|
10
|
+
cookie and no Authorization header is accepted only when the browser says it
|
|
11
|
+
comes from this same site:
|
|
12
|
+
|
|
13
|
+
1. `Sec-Fetch-Site: same-origin` (or `none`, typed by the person) is enough; every
|
|
14
|
+
current browser sends it.
|
|
15
|
+
2. Otherwise its `Origin`, or the origin of its `Referer`, must be this host, one
|
|
16
|
+
listed in IAT_CSRF_TRUSTED_ORIGINS, or one a company declares in `cors_origin`:
|
|
17
|
+
CORS already lets those call with credentials, and a portal that serves the chat
|
|
18
|
+
(Maxxa's) calls back from there with the session cookie.
|
|
19
|
+
3. A request with neither signal is not from a browser, and a forgery needs a
|
|
20
|
+
browser, so it passes.
|
|
21
|
+
|
|
22
|
+
No client changes are needed: the chat, the admin console, tenant apps and forms
|
|
23
|
+
already send these headers, and a page embedded in another site's iframe still
|
|
24
|
+
calls its own origin. Calls with an Authorization header (API keys, bearer tokens)
|
|
25
|
+
and requests without the session cookie are out of scope: nothing ambient to abuse.
|
|
26
|
+
|
|
27
|
+
Configuration (config dict or environment):
|
|
28
|
+
- IAT_CSRF_MODE: "enforce" (default), "report" (log what would be blocked) or "off".
|
|
29
|
+
- IAT_CSRF_TRUSTED_ORIGINS: other origins allowed to post with the session,
|
|
30
|
+
space separated, e.g. "https://portal.example.com".
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
import logging
|
|
34
|
+
import os
|
|
35
|
+
from urllib.parse import urlsplit
|
|
36
|
+
|
|
37
|
+
from flask import Flask, jsonify, request
|
|
38
|
+
|
|
39
|
+
UNSAFE_METHODS = frozenset({"POST", "PUT", "PATCH", "DELETE"})
|
|
40
|
+
SAME_SITE_SIGNALS = frozenset({"same-origin", "none"})
|
|
41
|
+
CSRF_MODES = ("enforce", "report", "off")
|
|
42
|
+
# Endpoints a browser reaches across sites on purpose and that change nothing a
|
|
43
|
+
# session owns.
|
|
44
|
+
EXEMPT_ENDPOINTS = frozenset({"csp_report"})
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _setting(app: Flask, config: dict | None, key: str, default: str) -> str:
|
|
48
|
+
value = config.get(key) if config else None
|
|
49
|
+
if value is None:
|
|
50
|
+
value = app.config.get(key)
|
|
51
|
+
if value is None:
|
|
52
|
+
value = os.getenv(key, default)
|
|
53
|
+
return str(value or default).strip()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _origin_of(url: str | None) -> str | None:
|
|
57
|
+
value = str(url or "").strip()
|
|
58
|
+
if not value or value == "null":
|
|
59
|
+
return None
|
|
60
|
+
parts = urlsplit(value)
|
|
61
|
+
if not parts.scheme or not parts.netloc:
|
|
62
|
+
return None
|
|
63
|
+
return f"{parts.scheme}://{parts.netloc}".lower()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def csrf_verdict(*, method: str, has_authorization: bool, has_session_cookie: bool, endpoint: str | None,
|
|
67
|
+
sec_fetch_site: str | None, origin: str | None, referer: str | None,
|
|
68
|
+
own_origin: str, trusted_origins: frozenset[str]) -> tuple[bool, str]:
|
|
69
|
+
"""(allowed, reason). Pure, so every rule can be tested on its own."""
|
|
70
|
+
if method.upper() not in UNSAFE_METHODS:
|
|
71
|
+
return True, "safe_method"
|
|
72
|
+
if has_authorization:
|
|
73
|
+
return True, "authorization_header"
|
|
74
|
+
if not has_session_cookie:
|
|
75
|
+
return True, "no_session_cookie"
|
|
76
|
+
if endpoint in EXEMPT_ENDPOINTS:
|
|
77
|
+
return True, "exempt_endpoint"
|
|
78
|
+
|
|
79
|
+
fetch_site = str(sec_fetch_site or "").strip().lower()
|
|
80
|
+
if fetch_site in SAME_SITE_SIGNALS:
|
|
81
|
+
return True, "same_origin_fetch"
|
|
82
|
+
|
|
83
|
+
source = _origin_of(origin) or _origin_of(referer)
|
|
84
|
+
if source:
|
|
85
|
+
if source == own_origin.lower() or source in trusted_origins:
|
|
86
|
+
return True, "trusted_origin"
|
|
87
|
+
return False, "foreign_origin"
|
|
88
|
+
if fetch_site: # cross-site or same-site with no origin to trust
|
|
89
|
+
return False, f"sec_fetch_site_{fetch_site}"
|
|
90
|
+
return True, "no_browser_signal"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def install_csrf_guard(app: Flask, config: dict | None = None) -> None:
|
|
94
|
+
if app.config.get("_IATOOLKIT_CSRF_GUARD_INSTALLED"):
|
|
95
|
+
return
|
|
96
|
+
app.config["_IATOOLKIT_CSRF_GUARD_INSTALLED"] = True
|
|
97
|
+
|
|
98
|
+
mode = _setting(app, config, "IAT_CSRF_MODE", "enforce").lower()
|
|
99
|
+
if mode not in CSRF_MODES:
|
|
100
|
+
logging.warning("IAT_CSRF_MODE=%s is not one of %s; using 'enforce'.", mode, ", ".join(CSRF_MODES))
|
|
101
|
+
mode = "enforce"
|
|
102
|
+
if mode == "off":
|
|
103
|
+
logging.warning("CSRF guard is off (IAT_CSRF_MODE=off).")
|
|
104
|
+
return
|
|
105
|
+
trusted = frozenset(
|
|
106
|
+
origin for origin in (_origin_of(item) for item in
|
|
107
|
+
_setting(app, config, "IAT_CSRF_TRUSTED_ORIGINS", "").split())
|
|
108
|
+
if origin)
|
|
109
|
+
|
|
110
|
+
@app.before_request
|
|
111
|
+
def _csrf_guard():
|
|
112
|
+
cookie_name = app.config.get("SESSION_COOKIE_NAME") or "session"
|
|
113
|
+
cors_origins = frozenset(
|
|
114
|
+
origin for origin in (_origin_of(item) for item in app.config.get("IAT_CORS_ORIGINS") or [])
|
|
115
|
+
if origin)
|
|
116
|
+
allowed, reason = csrf_verdict(
|
|
117
|
+
method=request.method,
|
|
118
|
+
has_authorization=bool(request.headers.get("Authorization")),
|
|
119
|
+
has_session_cookie=cookie_name in request.cookies,
|
|
120
|
+
endpoint=request.endpoint,
|
|
121
|
+
sec_fetch_site=request.headers.get("Sec-Fetch-Site"),
|
|
122
|
+
origin=request.headers.get("Origin"),
|
|
123
|
+
referer=request.headers.get("Referer"),
|
|
124
|
+
own_origin=f"{request.scheme}://{request.host}",
|
|
125
|
+
trusted_origins=trusted | cors_origins,
|
|
126
|
+
)
|
|
127
|
+
if allowed:
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
first_segment = request.path.strip("/").split("/", 1)[0][:40]
|
|
131
|
+
logging.warning(
|
|
132
|
+
"event=csrf_%s method=%s path=/%s reason=%s origin=%s sec_fetch_site=%s",
|
|
133
|
+
"blocked" if mode == "enforce" else "would_block", request.method, first_segment, reason,
|
|
134
|
+
_origin_of(request.headers.get("Origin")) or _origin_of(request.headers.get("Referer")),
|
|
135
|
+
request.headers.get("Sec-Fetch-Site"),
|
|
136
|
+
)
|
|
137
|
+
if mode == "report":
|
|
138
|
+
return None
|
|
139
|
+
return jsonify({"error": "forbidden", "error_message": "Cross-site request refused."}), 403
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Copyright (c) 2024 Fernando Libedinsky
|
|
2
|
+
# Product: IAToolkit
|
|
3
|
+
#
|
|
4
|
+
# IAToolkit is open source software.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Rate limits on the doors that guess credentials (BL-030, PR-10).
|
|
8
|
+
|
|
9
|
+
Fixed windows in Redis, per client IP and, where there is one, per account. A
|
|
10
|
+
limit is a (max_hits, window_seconds) pair; `over_limit` counts one hit and says
|
|
11
|
+
whether it went past the limit. Failures are counted with `record_failure`, and
|
|
12
|
+
`clear` forgets them after a success.
|
|
13
|
+
|
|
14
|
+
Fails open: if Redis cannot answer, nothing is blocked. Sessions live in the same
|
|
15
|
+
Redis, so with it down there is no login to protect anyway, and a limiter that
|
|
16
|
+
locked everybody out would turn a Redis hiccup into an outage.
|
|
17
|
+
|
|
18
|
+
IAT_RATE_LIMITS=off turns every limit off (automated end-to-end tests).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import hashlib
|
|
22
|
+
import logging
|
|
23
|
+
import os
|
|
24
|
+
|
|
25
|
+
from iatoolkit.infra.redis_session_manager import RedisSessionManager
|
|
26
|
+
|
|
27
|
+
KEY_PREFIX = "iat:ratelimit"
|
|
28
|
+
|
|
29
|
+
# (max hits, window in seconds)
|
|
30
|
+
LOGIN_FAILURES_PER_ACCOUNT = (10, 15 * 60)
|
|
31
|
+
LOGIN_ATTEMPTS_PER_IP = (50, 15 * 60)
|
|
32
|
+
PASSWORD_RESET_REQUESTS_PER_ACCOUNT = (5, 60 * 60)
|
|
33
|
+
PASSWORD_RESET_REQUESTS_PER_IP = (20, 60 * 60)
|
|
34
|
+
PASSWORD_CHANGE_ATTEMPTS_PER_IP = (20, 15 * 60)
|
|
35
|
+
TOKEN_REDEEMS_PER_IP = (60, 60)
|
|
36
|
+
INVALID_API_KEYS_PER_IP = (30, 60)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def enabled() -> bool:
|
|
40
|
+
return os.getenv("IAT_RATE_LIMITS", "on").strip().lower() not in ("off", "false", "0")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _key(bucket: str, identity: str) -> str:
|
|
44
|
+
# Hashed so emails and IPs are not readable from Redis keys.
|
|
45
|
+
digest = hashlib.sha256(str(identity or "").strip().lower().encode("utf-8")).hexdigest()[:32]
|
|
46
|
+
return f"{KEY_PREFIX}:{bucket}:{digest}"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _incr(key: str, window_seconds: int) -> int:
|
|
50
|
+
try:
|
|
51
|
+
pipe = RedisSessionManager.pipeline()
|
|
52
|
+
pipe.incr(key)
|
|
53
|
+
pipe.ttl(key)
|
|
54
|
+
count, ttl = pipe.execute()
|
|
55
|
+
if ttl is None or int(ttl) < 0:
|
|
56
|
+
RedisSessionManager.pipeline().expire(key, window_seconds).execute()
|
|
57
|
+
return int(count)
|
|
58
|
+
except Exception as exc:
|
|
59
|
+
logging.warning("rate limiter unavailable, letting the request through (%s)", exc)
|
|
60
|
+
return 0
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _peek(key: str) -> int | None:
|
|
64
|
+
"""The current count, or None when Redis cannot answer (which never blocks)."""
|
|
65
|
+
try:
|
|
66
|
+
return int(RedisSessionManager.get(key, "0") or 0)
|
|
67
|
+
except Exception as exc:
|
|
68
|
+
logging.warning("rate limiter unavailable, letting the request through (%s)", exc)
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def over_limit(bucket: str, identity: str | None, limit: tuple[int, int]) -> bool:
|
|
73
|
+
"""Counts one hit for `identity` and says whether it went past `limit`."""
|
|
74
|
+
if not identity or not enabled():
|
|
75
|
+
return False
|
|
76
|
+
max_hits, window = limit
|
|
77
|
+
over = _incr(_key(bucket, identity), window) > max_hits
|
|
78
|
+
if over:
|
|
79
|
+
logging.warning("event=rate_limited bucket=%s", bucket)
|
|
80
|
+
return over
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def is_blocked(bucket: str, identity: str | None, limit: tuple[int, int]) -> bool:
|
|
84
|
+
"""Whether `identity` already used up `limit`, without counting a hit."""
|
|
85
|
+
if not identity or not enabled():
|
|
86
|
+
return False
|
|
87
|
+
count = _peek(_key(bucket, identity))
|
|
88
|
+
blocked = count is not None and count >= limit[0]
|
|
89
|
+
if blocked:
|
|
90
|
+
logging.warning("event=rate_limited bucket=%s", bucket)
|
|
91
|
+
return blocked
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def record_failure(bucket: str, identity: str | None, limit: tuple[int, int]) -> None:
|
|
95
|
+
if identity and enabled():
|
|
96
|
+
_incr(_key(bucket, identity), limit[1])
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def clear(bucket: str, identity: str | None) -> None:
|
|
100
|
+
if not identity:
|
|
101
|
+
return
|
|
102
|
+
try:
|
|
103
|
+
RedisSessionManager.remove(_key(bucket, identity))
|
|
104
|
+
except Exception as exc:
|
|
105
|
+
logging.warning("rate limiter unavailable (%s)", exc)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def client_ip(request) -> str | None:
|
|
109
|
+
"""The real client IP; same rules as the signup guard (Cloudflare, proxy hops)."""
|
|
110
|
+
from iatoolkit.services.signup_guard_service import SignupGuardService
|
|
111
|
+
return SignupGuardService.client_ip(request)
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Copyright (c) 2024 Fernando Libedinsky
|
|
2
|
+
# Product: IAToolkit
|
|
3
|
+
#
|
|
4
|
+
# IAToolkit is open source software.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Security headers on every response (BL-030, PR-7).
|
|
8
|
+
|
|
9
|
+
Always on: HSTS on HTTPS requests, `X-Content-Type-Options: nosniff` and a
|
|
10
|
+
`Referrer-Policy` that keeps paths (which can carry tokens) out of other sites.
|
|
11
|
+
|
|
12
|
+
The Content-Security-Policy, `frame-ancestors` included, starts in report-only
|
|
13
|
+
mode: browsers report what the policy would block to `/csp-report`, which logs it,
|
|
14
|
+
and nothing is blocked. That tells, in production, which portals embed IAToolkit
|
|
15
|
+
and which outside resources pages really use, before the policy is enforced.
|
|
16
|
+
|
|
17
|
+
Configuration (config dict or environment):
|
|
18
|
+
- IAT_CSP_MODE: "report" (default), "enforce" or "off".
|
|
19
|
+
- IAT_FRAME_ANCESTORS: who may embed the pages, space separated
|
|
20
|
+
(default "'self'"), e.g. "'self' https://portal.example.com".
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import json
|
|
24
|
+
import logging
|
|
25
|
+
import os
|
|
26
|
+
from urllib.parse import urlsplit
|
|
27
|
+
|
|
28
|
+
from flask import Flask, request
|
|
29
|
+
|
|
30
|
+
CSP_REPORT_PATH = "/csp-report"
|
|
31
|
+
CSP_MODES = ("report", "enforce", "off")
|
|
32
|
+
DEFAULT_FRAME_ANCESTORS = "'self'"
|
|
33
|
+
# Sources the templates load today: the CDNs for scripts, styles and fonts, Google
|
|
34
|
+
# Tag Manager on the public site and Google Fonts.
|
|
35
|
+
CDN_SOURCES = "https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://unpkg.com https://code.jquery.com"
|
|
36
|
+
HSTS_VALUE = "max-age=31536000"
|
|
37
|
+
MAX_REPORT_BYTES = 16 * 1024
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def build_csp(frame_ancestors: str) -> str:
|
|
41
|
+
directives = [
|
|
42
|
+
"default-src 'self'",
|
|
43
|
+
f"script-src 'self' 'unsafe-inline' {CDN_SOURCES} https://www.googletagmanager.com",
|
|
44
|
+
f"style-src 'self' 'unsafe-inline' {CDN_SOURCES} https://fonts.googleapis.com",
|
|
45
|
+
f"font-src 'self' data: {CDN_SOURCES} https://fonts.gstatic.com",
|
|
46
|
+
"img-src 'self' data: blob: https:",
|
|
47
|
+
"connect-src 'self'",
|
|
48
|
+
"frame-src 'self'",
|
|
49
|
+
f"frame-ancestors {frame_ancestors}",
|
|
50
|
+
"object-src 'none'",
|
|
51
|
+
"base-uri 'self'",
|
|
52
|
+
"form-action 'self'",
|
|
53
|
+
f"report-uri {CSP_REPORT_PATH}",
|
|
54
|
+
]
|
|
55
|
+
return "; ".join(directives)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _setting(app: Flask, config: dict, key: str, default: str) -> str:
|
|
59
|
+
value = config.get(key) if config else None
|
|
60
|
+
if value is None:
|
|
61
|
+
value = app.config.get(key)
|
|
62
|
+
if value is None:
|
|
63
|
+
value = os.getenv(key, default)
|
|
64
|
+
return str(value or default).strip()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def install_security_headers(app: Flask, config: dict | None = None) -> None:
|
|
68
|
+
if app.config.get("_IATOOLKIT_SECURITY_HEADERS_INSTALLED"):
|
|
69
|
+
return
|
|
70
|
+
app.config["_IATOOLKIT_SECURITY_HEADERS_INSTALLED"] = True
|
|
71
|
+
|
|
72
|
+
mode = _setting(app, config, "IAT_CSP_MODE", "report").lower()
|
|
73
|
+
if mode not in CSP_MODES:
|
|
74
|
+
logging.warning("IAT_CSP_MODE=%s is not one of %s; using 'report'.", mode, ", ".join(CSP_MODES))
|
|
75
|
+
mode = "report"
|
|
76
|
+
frame_ancestors = _setting(app, config, "IAT_FRAME_ANCESTORS", DEFAULT_FRAME_ANCESTORS)
|
|
77
|
+
csp = build_csp(frame_ancestors)
|
|
78
|
+
csp_header = {"report": "Content-Security-Policy-Report-Only",
|
|
79
|
+
"enforce": "Content-Security-Policy"}.get(mode)
|
|
80
|
+
|
|
81
|
+
@app.after_request
|
|
82
|
+
def _security_headers(response):
|
|
83
|
+
headers = response.headers
|
|
84
|
+
headers.setdefault("X-Content-Type-Options", "nosniff")
|
|
85
|
+
headers.setdefault("Referrer-Policy", "strict-origin-when-cross-origin")
|
|
86
|
+
if request.is_secure:
|
|
87
|
+
headers.setdefault("Strict-Transport-Security", HSTS_VALUE)
|
|
88
|
+
if csp_header and "Content-Security-Policy" not in headers \
|
|
89
|
+
and "Content-Security-Policy-Report-Only" not in headers:
|
|
90
|
+
headers[csp_header] = csp
|
|
91
|
+
return response
|
|
92
|
+
|
|
93
|
+
app.add_url_rule(CSP_REPORT_PATH, "csp_report", _csp_report, methods=["POST"])
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _where(uri) -> str:
|
|
97
|
+
"""Origin and first path segment only: full URLs can carry tokens
|
|
98
|
+
(finalize/<token>, links with codes), which must not reach the logs."""
|
|
99
|
+
value = str(uri or "").strip()
|
|
100
|
+
if not value or "://" not in value:
|
|
101
|
+
return value[:40] # keywords such as 'inline' or 'eval'
|
|
102
|
+
parts = urlsplit(value)
|
|
103
|
+
first = parts.path.strip("/").split("/", 1)[0]
|
|
104
|
+
return f"{parts.scheme}://{parts.netloc}/{first[:40]}"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _csp_report():
|
|
108
|
+
"""Logs what the policy reported; always answers 204 and never fails."""
|
|
109
|
+
try:
|
|
110
|
+
if (request.content_length or 0) > MAX_REPORT_BYTES:
|
|
111
|
+
return "", 204
|
|
112
|
+
payload = json.loads(request.get_data(cache=False, as_text=True) or "{}")
|
|
113
|
+
reports = payload if isinstance(payload, list) else [payload]
|
|
114
|
+
for item in reports[:10]:
|
|
115
|
+
body = item.get("csp-report") or item.get("body") or {}
|
|
116
|
+
logging.warning(
|
|
117
|
+
"event=csp_violation directive=%s blocked=%s document=%s disposition=%s",
|
|
118
|
+
body.get("effective-directive") or body.get("effectiveDirective") or body.get("violated-directive"),
|
|
119
|
+
_where(body.get("blocked-uri") or body.get("blockedURL")),
|
|
120
|
+
_where(body.get("document-uri") or body.get("documentURL")),
|
|
121
|
+
body.get("disposition"),
|
|
122
|
+
)
|
|
123
|
+
except Exception as exc: # a malformed report is not worth an error
|
|
124
|
+
logging.debug("Ignoring an unreadable CSP report: %s", exc)
|
|
125
|
+
return "", 204
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright (c) 2024 Fernando Libedinsky
|
|
2
|
+
# Product: IAToolkit
|
|
3
|
+
#
|
|
4
|
+
# IAToolkit is open source software.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Unexpected errors as a person sees them.
|
|
8
|
+
|
|
9
|
+
The text of an exception can carry SQL, table and column names, file paths or
|
|
10
|
+
configuration: shown to the user it maps the system for anyone probing it. So the
|
|
11
|
+
person gets a generic message with a short reference, and the exception goes to the
|
|
12
|
+
log under that same reference, where support can find it (BL-030, gap #24).
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import logging
|
|
16
|
+
import secrets
|
|
17
|
+
|
|
18
|
+
GENERAL_KEY = "errors.general.unexpected_error_ref"
|
|
19
|
+
PAGE_KEY = "errors.templates.processing_error"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def new_error_ref() -> str:
|
|
23
|
+
"""A short reference that ties what the person sees to the log line."""
|
|
24
|
+
return secrets.token_hex(4)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def unexpected_error_message(i18n_service, exc: BaseException, *, where: str, key: str = GENERAL_KEY) -> str:
|
|
28
|
+
"""Logs `exc` with a reference and returns the translated generic message for it.
|
|
29
|
+
|
|
30
|
+
`key` must be a translation that takes `{ref}` and never shows the exception.
|
|
31
|
+
"""
|
|
32
|
+
ref = new_error_ref()
|
|
33
|
+
logging.error("Unexpected error in %s [ref=%s]: %s", where, ref, exc, exc_info=exc)
|
|
34
|
+
return i18n_service.t(key, ref=ref)
|
|
@@ -25,11 +25,34 @@ import threading
|
|
|
25
25
|
|
|
26
26
|
from iatoolkit import __version__ as IATOOLKIT_VERSION
|
|
27
27
|
from iatoolkit.runtime_logging import configure_runtime_logging, install_flask_request_logging
|
|
28
|
+
from iatoolkit.common.security_headers import install_security_headers
|
|
29
|
+
from iatoolkit.common.csrf_guard import install_csrf_guard
|
|
28
30
|
from iatoolkit.services.configuration_service import ConfigurationService
|
|
29
31
|
|
|
30
32
|
# global variable for the unique instance of IAToolkit
|
|
31
33
|
_iatoolkit_instance: Optional['IAToolkit'] = None
|
|
32
34
|
|
|
35
|
+
# Environments where the signing secrets may fall back to a development value.
|
|
36
|
+
# Anything else, an unset FLASK_ENV included, is treated as production.
|
|
37
|
+
NON_PRODUCTION_ENVS = frozenset({'dev', 'development', 'test', 'testing'})
|
|
38
|
+
|
|
39
|
+
# The secrets that sign sessions and tokens, with the value each one falls back to
|
|
40
|
+
# outside production.
|
|
41
|
+
SIGNING_SECRETS = {
|
|
42
|
+
'FLASK_SECRET_KEY': 'iatoolkit-default-secret',
|
|
43
|
+
'IATOOLKIT_SECRET_KEY': 'iatoolkit-jwt-secret',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Values that are public, so signing with them signs nothing: the development
|
|
47
|
+
# fallbacks above and the placeholders the docs and templates show.
|
|
48
|
+
KNOWN_PLACEHOLDER_SECRETS = frozenset({
|
|
49
|
+
'iatoolkit-default-secret',
|
|
50
|
+
'iatoolkit-jwt-secret',
|
|
51
|
+
'define-your-own-key',
|
|
52
|
+
'una_clave_larga',
|
|
53
|
+
'a-long-random-string',
|
|
54
|
+
})
|
|
55
|
+
|
|
33
56
|
def is_bound(injector: Injector, cls) -> bool:
|
|
34
57
|
return cls in injector.binder._bindings
|
|
35
58
|
|
|
@@ -244,6 +267,24 @@ class IAToolkit:
|
|
|
244
267
|
register_views(self.app)
|
|
245
268
|
logging.info("✅ Community routes registered.")
|
|
246
269
|
|
|
270
|
+
def _get_signing_secret(self, name: str, flask_env: str) -> str:
|
|
271
|
+
"""
|
|
272
|
+
A secret that signs sessions or tokens. Outside production it falls back to a
|
|
273
|
+
development value; in production a missing or publicly known value stops the
|
|
274
|
+
boot, because anyone could forge what it signs.
|
|
275
|
+
"""
|
|
276
|
+
value = str(self._get_config_value(name, '') or '').strip()
|
|
277
|
+
if flask_env in NON_PRODUCTION_ENVS:
|
|
278
|
+
return value or SIGNING_SECRETS[name]
|
|
279
|
+
if not value or value in KNOWN_PLACEHOLDER_SECRETS:
|
|
280
|
+
raise IAToolkitException(
|
|
281
|
+
IAToolkitException.ErrorType.CONFIG_ERROR,
|
|
282
|
+
f"{name} must be set to a private random value in production "
|
|
283
|
+
f"(FLASK_ENV={flask_env or 'unset'}). Generate one with: "
|
|
284
|
+
f"python -c \"import secrets; print(secrets.token_hex(32))\""
|
|
285
|
+
)
|
|
286
|
+
return value
|
|
287
|
+
|
|
247
288
|
def _create_flask_instance(self):
|
|
248
289
|
static_folder = self._get_config_value('STATIC_FOLDER') or self._get_default_static_folder()
|
|
249
290
|
template_folder = self._get_config_value('TEMPLATE_FOLDER') or self._get_default_template_folder()
|
|
@@ -258,6 +299,8 @@ class IAToolkit:
|
|
|
258
299
|
session_cookie_samesite = str(
|
|
259
300
|
self._get_config_value('SESSION_COOKIE_SAMESITE', session_cookie_samesite_default)
|
|
260
301
|
).strip()
|
|
302
|
+
flask_secret_key = self._get_signing_secret('FLASK_SECRET_KEY', flask_env)
|
|
303
|
+
iatoolkit_secret_key = self._get_signing_secret('IATOOLKIT_SECRET_KEY', flask_env)
|
|
261
304
|
session_cookie_name = str(self._get_config_value('SESSION_COOKIE_NAME', 'session')).strip() or 'session'
|
|
262
305
|
session_key_prefix = str(self._get_config_value('SESSION_KEY_PREFIX', 'session:')).strip() or 'session:'
|
|
263
306
|
|
|
@@ -267,7 +310,7 @@ class IAToolkit:
|
|
|
267
310
|
|
|
268
311
|
self.app.config.update({
|
|
269
312
|
'VERSION': self.version,
|
|
270
|
-
'SECRET_KEY':
|
|
313
|
+
'SECRET_KEY': flask_secret_key,
|
|
271
314
|
'SESSION_COOKIE_NAME': session_cookie_name,
|
|
272
315
|
'SESSION_COOKIE_SAMESITE': session_cookie_samesite,
|
|
273
316
|
'SESSION_COOKIE_SECURE': session_cookie_secure,
|
|
@@ -276,13 +319,18 @@ class IAToolkit:
|
|
|
276
319
|
'PERMANENT_SESSION_LIFETIME': timedelta(minutes=idle_timeout_minutes),
|
|
277
320
|
'SESSION_REFRESH_EACH_REQUEST': True,
|
|
278
321
|
'SESSION_USE_SIGNER': True,
|
|
279
|
-
'IATOOLKIT_SECRET_KEY':
|
|
322
|
+
'IATOOLKIT_SECRET_KEY': iatoolkit_secret_key,
|
|
280
323
|
'JWT_ALGORITHM': 'HS256',
|
|
281
324
|
})
|
|
282
325
|
|
|
283
326
|
# 2. ProxyFix para no tener problemas con iframes y rutas
|
|
284
327
|
self.app.wsgi_app = ProxyFix(self.app.wsgi_app, x_proto=1)
|
|
285
328
|
|
|
329
|
+
# Security headers on every response; the CSP starts in report-only (BL-030).
|
|
330
|
+
install_security_headers(self.app, self.config)
|
|
331
|
+
# Refuses cross-site requests that ride on the session cookie (BL-030).
|
|
332
|
+
install_csrf_guard(self.app, self.config)
|
|
333
|
+
|
|
286
334
|
# Configuración para tokenizers en desarrollo
|
|
287
335
|
if flask_env == 'dev':
|
|
288
336
|
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
@@ -357,6 +405,9 @@ class IAToolkit:
|
|
|
357
405
|
extra_origins += cors_origin
|
|
358
406
|
|
|
359
407
|
all_origins = default_origins + extra_origins
|
|
408
|
+
# The same origins may post with the session cookie: the CSRF guard trusts
|
|
409
|
+
# them (BL-030). Maxxa's portal serves the chat and calls back this way.
|
|
410
|
+
self.app.config['IAT_CORS_ORIGINS'] = list(all_origins)
|
|
360
411
|
|
|
361
412
|
CORS(self.app,
|
|
362
413
|
supports_credentials=True,
|
|
@@ -2333,6 +2333,8 @@ ui:
|
|
|
2333
2333
|
copy_tooltip: "Copy API key"
|
|
2334
2334
|
copy_success: "API key copied to clipboard."
|
|
2335
2335
|
copy_error: "Could not copy API key."
|
|
2336
|
+
key_shown_once_hint: "Copy it now: only its fingerprint is stored and it will not be shown again."
|
|
2337
|
+
key_prefix_hint: "Only the first characters are kept. If you lost the key, create a new one and delete this one."
|
|
2336
2338
|
status: "Status"
|
|
2337
2339
|
active: "Active"
|
|
2338
2340
|
inactive: "Inactive"
|
|
@@ -2366,6 +2368,8 @@ ui:
|
|
|
2366
2368
|
api_key: "API Key"
|
|
2367
2369
|
api_key_masked: "••••••••••••"
|
|
2368
2370
|
api_key_help: "Set this value as IAT_BRIDGE_KEY in the bridge's .env file."
|
|
2371
|
+
api_key_shown_once_hint: "Copy it now into IAT_BRIDGE_KEY in the bridge's .env: it will not be shown again."
|
|
2372
|
+
api_key_prefix_hint: "Only the first characters are kept. If you lost the key, rotate it to get a new one."
|
|
2369
2373
|
copy_tooltip: "Copy API key"
|
|
2370
2374
|
copy_success: "API key copied to clipboard."
|
|
2371
2375
|
copy_error: "Could not copy the API key."
|
|
@@ -2866,6 +2870,7 @@ errors:
|
|
|
2866
2870
|
model_denied: "You do not have access to the model {model}."
|
|
2867
2871
|
timeout: "timeout expired."
|
|
2868
2872
|
auth:
|
|
2873
|
+
too_many_attempts: "Too many attempts. Wait a few minutes and try again."
|
|
2869
2874
|
invalid_password: "The provided password is incorrect."
|
|
2870
2875
|
user_not_found: "A user with that email address was not found."
|
|
2871
2876
|
google_account_requires_google_login: "This account uses Google sign-in. Continue with Google to log in."
|
|
@@ -2894,9 +2899,10 @@ errors:
|
|
|
2894
2899
|
company_not_found: "Company not found."
|
|
2895
2900
|
home_template_not_found: "The home page template for the company '{company_short_name}' is not configured."
|
|
2896
2901
|
template_not_found: "Template not found: '{template_name}'."
|
|
2897
|
-
processing_error: "
|
|
2902
|
+
processing_error: "We could not load this page. If the problem persists, contact support with reference {ref}."
|
|
2898
2903
|
general:
|
|
2899
2904
|
unexpected_error: "An unexpected error has occurred. Please contact support."
|
|
2905
|
+
unexpected_error_ref: "An unexpected error has occurred. If the problem persists, contact support with reference {ref}."
|
|
2900
2906
|
unsupported_language: "The selected language is not supported."
|
|
2901
2907
|
signup:
|
|
2902
2908
|
company_not_found: "The company {company_short_name} does not exist."
|
|
@@ -2351,6 +2351,8 @@ ui:
|
|
|
2351
2351
|
copy_tooltip: "Copiar API key"
|
|
2352
2352
|
copy_success: "API key copiada al portapapeles."
|
|
2353
2353
|
copy_error: "No se pudo copiar la API key."
|
|
2354
|
+
key_shown_once_hint: "Cópiala ahora: solo se guarda su huella y no se volverá a mostrar."
|
|
2355
|
+
key_prefix_hint: "Solo se guardan los primeros caracteres. Si perdiste la llave, crea una nueva y elimina esta."
|
|
2354
2356
|
status: "Estado"
|
|
2355
2357
|
active: "Activa"
|
|
2356
2358
|
inactive: "Inactiva"
|
|
@@ -2384,6 +2386,8 @@ ui:
|
|
|
2384
2386
|
api_key: "API Key"
|
|
2385
2387
|
api_key_masked: "••••••••••••"
|
|
2386
2388
|
api_key_help: "Configura este valor como IAT_BRIDGE_KEY en el .env del bridge."
|
|
2389
|
+
api_key_shown_once_hint: "Cópiala ahora en IAT_BRIDGE_KEY del .env del bridge: no se volverá a mostrar."
|
|
2390
|
+
api_key_prefix_hint: "Solo se guardan los primeros caracteres. Si perdiste la llave, rótala para obtener una nueva."
|
|
2387
2391
|
copy_tooltip: "Copiar API key"
|
|
2388
2392
|
copy_success: "API key copiada al portapapeles."
|
|
2389
2393
|
copy_error: "No se pudo copiar la API key."
|
|
@@ -2883,6 +2887,7 @@ errors:
|
|
|
2883
2887
|
|
|
2884
2888
|
|
|
2885
2889
|
auth:
|
|
2890
|
+
too_many_attempts: "Demasiados intentos. Espera unos minutos e inténtalo de nuevo."
|
|
2886
2891
|
invalid_password: "La contraseña proporcionada es incorrecta."
|
|
2887
2892
|
user_not_found: "No se encontró un usuario con ese correo."
|
|
2888
2893
|
google_account_requires_google_login: "Esta cuenta usa acceso con Google. Continúa con Google para iniciar sesión."
|
|
@@ -2911,11 +2916,12 @@ errors:
|
|
|
2911
2916
|
templates:
|
|
2912
2917
|
company_not_found: "Empresa no encontrada."
|
|
2913
2918
|
home_template_not_found: "La plantilla de la página de inicio para la empresa '{company_short_name}' no está configurada."
|
|
2914
|
-
processing_error: "
|
|
2919
|
+
processing_error: "No pudimos cargar esta página. Si el problema persiste, contacta a soporte e indica la referencia {ref}."
|
|
2915
2920
|
template_not_found: "No se encontro el template: '{template_name}'."
|
|
2916
2921
|
|
|
2917
2922
|
general:
|
|
2918
|
-
unexpected_error: "Ha ocurrido un error inesperado
|
|
2923
|
+
unexpected_error: "Ha ocurrido un error inesperado. Si el problema persiste, contacta a soporte."
|
|
2924
|
+
unexpected_error_ref: "Ha ocurrido un error inesperado. Si el problema persiste, contacta a soporte e indica la referencia {ref}."
|
|
2919
2925
|
unsupported_language: "El idioma seleccionado no es válido."
|
|
2920
2926
|
signup:
|
|
2921
2927
|
company_not_found: "La empresa {company_short_name} no existe."
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# IAToolkit is open source software.
|
|
5
5
|
|
|
6
|
+
import hashlib
|
|
6
7
|
from injector import inject
|
|
7
8
|
from iatoolkit.repositories.database_manager import DatabaseManager
|
|
8
9
|
from iatoolkit.repositories.models import ApiKey, Company
|
|
@@ -50,10 +51,17 @@ class ApiKeyRepo:
|
|
|
50
51
|
self.session.delete(api_key)
|
|
51
52
|
self.session.commit()
|
|
52
53
|
|
|
54
|
+
@staticmethod
|
|
55
|
+
def hash_key(api_key_value: str) -> str:
|
|
56
|
+
"""What is stored and searched for a key: its SHA-256, never the key (BL-030)."""
|
|
57
|
+
return hashlib.sha256(str(api_key_value or '').encode('utf-8')).hexdigest()
|
|
58
|
+
|
|
53
59
|
def get_active_api_key_entry(self, api_key_value: str) -> ApiKey | None:
|
|
60
|
+
if not api_key_value:
|
|
61
|
+
return None
|
|
54
62
|
return (
|
|
55
63
|
self.session.query(ApiKey)
|
|
56
|
-
.filter(ApiKey.
|
|
64
|
+
.filter(ApiKey.key_hash == self.hash_key(api_key_value), ApiKey.is_active == True)
|
|
57
65
|
.first()
|
|
58
66
|
)
|
|
59
67
|
|