From 3c747bc6d0f2bb57385958d0a0f219d3f4a95ada Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Thu, 29 Aug 2024 16:53:55 +0800 Subject: [PATCH] feat: add system future config --- api/.env.example | 3 +++ api/configs/feature/__init__.py | 12 ++++++++++++ api/services/feature_service.py | 3 +++ docker/.env.example | 13 ++++++++++--- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api/.env.example b/api/.env.example index 22287e6b34..d4f8d9905a 100644 --- a/api/.env.example +++ b/api/.env.example @@ -279,6 +279,9 @@ POSITION_PROVIDER_INCLUDES= POSITION_PROVIDER_EXCLUDES= # Login +ENABLE_EMAIL_CODE_LOGIN= +ENABLE_EMAIL_PASSWORD_LOGIN= +ENABLE_SOCIAL_OAUTH_LOGIN= EMAIL_CODE_LOGIN_TOKEN_EXPIRY_HOURS=1/12 ALLOW_REGISTER=true ALLOW_CREATE_WORKSPACE=true \ No newline at end of file diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py index 6b62951b9e..d9e7038091 100644 --- a/api/configs/feature/__init__.py +++ b/api/configs/feature/__init__.py @@ -612,6 +612,18 @@ class PositionConfig(BaseSettings): class LoginConfig(BaseSettings): + ENABLE_EMAIL_CODE_LOGIN: bool = Field( + description="whether to enable email code login", + default=True, + ) + ENABLE_EMAIL_PASSWORD_LOGIN: bool = Field( + description="whether to enable email password login", + default=True, + ) + ENABLE_SOCIAL_OAUTH_LOGIN: bool = Field( + description="whether to enable github/google oauth login", + default=True, + ) EMAIL_CODE_LOGIN_TOKEN_EXPIRY_HOURS: PositiveFloat = Field( description="expiry time in hours for email code login token", default=1 / 12, diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 4d5812c6c6..72ab9b0e68 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -42,6 +42,9 @@ class SystemFeatureModel(BaseModel): sso_enforced_for_web: bool = False sso_enforced_for_web_protocol: str = "" enable_web_sso_switch_component: bool = False + enable_email_code_login: bool = dify_config.ENABLE_EMAIL_CODE_LOGIN + enable_email_password_login: bool = dify_config.ENABLE_EMAIL_PASSWORD_LOGIN + enable_social_oauth_login: bool = dify_config.ENABLE_SOCIAL_OAUTH_LOGIN class FeatureService: diff --git a/docker/.env.example b/docker/.env.example index 7233c4e671..d090a2fe70 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -507,8 +507,7 @@ INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=1000 INVITE_EXPIRY_HOURS=72 # Reset password token valid time (hours), -# Default: 24. -RESET_PASSWORD_TOKEN_EXPIRY_HOURS=24 +RESET_PASSWORD_TOKEN_EXPIRY_HOURS=1/12 # The sandbox service endpoint. CODE_EXECUTION_ENDPOINT=http://sandbox:8194 @@ -721,4 +720,12 @@ POSITION_TOOL_EXCLUDES= # Example: POSITION_PROVIDER_PINS=openai,openllm POSITION_PROVIDER_PINS= POSITION_PROVIDER_INCLUDES= -POSITION_PROVIDER_EXCLUDES= \ No newline at end of file +POSITION_PROVIDER_EXCLUDES= + +# LoginConfig +ENABLE_EMAIL_CODE_LOGIN= +ENABLE_EMAIL_PASSWORD_LOGIN= +ENABLE_SOCIAL_OAUTH_LOGIN= +EMAIL_CODE_LOGIN_TOKEN_EXPIRY_HOURS=1/12 +ALLOW_REGISTER=true +ALLOW_CREATE_WORKSPACE=true \ No newline at end of file