浏览代码

:wrench: Add env variable for time signature (#4650)

tags/0.6.9
Patryk Garstecki 1年前
父节点
当前提交
f40743183e
没有帐户链接到提交者的电子邮件
共有 5 个文件被更改,包括 13 次插入2 次删除
  1. 3
    0
      api/.env.example
  2. 5
    0
      api/config.py
  3. 1
    1
      api/core/file/upload_file_parser.py
  4. 1
    1
      api/core/tools/tool_file_manager.py
  5. 3
    0
      docker/docker-compose.yaml

+ 3
- 0
api/.env.example 查看文件

# Files URL # Files URL
FILES_URL=http://127.0.0.1:5001 FILES_URL=http://127.0.0.1:5001


# The time in seconds after the signature is rejected
FILES_ACCESS_TIMEOUT=300

# celery configuration # celery configuration
CELERY_BROKER_URL=redis://:difyai123456@localhost:6379/1 CELERY_BROKER_URL=redis://:difyai123456@localhost:6379/1



+ 5
- 0
api/config.py 查看文件

'SERVICE_API_URL': 'https://api.dify.ai', 'SERVICE_API_URL': 'https://api.dify.ai',
'APP_WEB_URL': 'https://udify.app', 'APP_WEB_URL': 'https://udify.app',
'FILES_URL': '', 'FILES_URL': '',
'FILES_ACCESS_TIMEOUT': 300,
'S3_ADDRESS_STYLE': 'auto', 'S3_ADDRESS_STYLE': 'auto',
'STORAGE_TYPE': 'local', 'STORAGE_TYPE': 'local',
'STORAGE_LOCAL_PATH': 'storage', 'STORAGE_LOCAL_PATH': 'storage',
# Url is signed and has expiration time. # Url is signed and has expiration time.
self.FILES_URL = get_env('FILES_URL') if get_env('FILES_URL') else self.CONSOLE_API_URL self.FILES_URL = get_env('FILES_URL') if get_env('FILES_URL') else self.CONSOLE_API_URL


# File Access Time specifies a time interval in seconds for the file to be accessed.
# The default value is 300 seconds.
self.FILES_ACCESS_TIMEOUT = int(get_env('FILES_ACCESS_TIMEOUT'))

# Your App secret key will be used for securely signing the session cookie # Your App secret key will be used for securely signing the session cookie
# Make sure you are changing this key for your deployment with a strong key. # Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`. # You can generate a strong key using `openssl rand -base64 42`.

+ 1
- 1
api/core/file/upload_file_parser.py 查看文件

return False return False


current_time = int(time.time()) current_time = int(time.time())
return current_time - int(timestamp) <= 300 # expired after 5 minutes
return current_time - int(timestamp) <= current_app.config.get('FILES_ACCESS_TIMEOUT')

+ 1
- 1
api/core/tools/tool_file_manager.py 查看文件

return False return False


current_time = int(time.time()) current_time = int(time.time())
return current_time - int(timestamp) <= 300 # expired after 5 minutes
return current_time - int(timestamp) <= current_app.config.get('FILES_ACCESS_TIMEOUT')


@staticmethod @staticmethod
def create_file_by_raw(user_id: str, tenant_id: str, def create_file_by_raw(user_id: str, tenant_id: str,

+ 3
- 0
docker/docker-compose.yaml 查看文件

# used to display File preview or download Url to the front-end or as Multi-model inputs; # used to display File preview or download Url to the front-end or as Multi-model inputs;
# Url is signed and has expiration time. # Url is signed and has expiration time.
FILES_URL: '' FILES_URL: ''
# File Access Time specifies a time interval in seconds for the file to be accessed.
# The default value is 300 seconds.
FILES_ACCESS_TIMEOUT: 300
# When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed. # When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
MIGRATION_ENABLED: 'true' MIGRATION_ENABLED: 'true'
# The configurations of postgres database connection. # The configurations of postgres database connection.

正在加载...
取消
保存