Merge branch 'e-260' into deploy/enterprise

This commit is contained in:
GareArc 2025-04-11 03:26:04 -04:00
commit 10df6d27f5

View File

@ -46,9 +46,14 @@ class BrandingModel(BaseModel):
favicon: str = "" favicon: str = ""
class WebAppAuthSSOModel(BaseModel):
protocol: str = ""
class WebAppAuthModel(BaseModel): class WebAppAuthModel(BaseModel):
enabled: bool = False enabled: bool = False
allow_sso: bool = False allow_sso: bool = False
sso_config: WebAppAuthSSOModel = WebAppAuthSSOModel()
allow_email_code_login: bool = False allow_email_code_login: bool = False
allow_email_password_login: bool = False allow_email_password_login: bool = False
@ -74,9 +79,6 @@ class FeatureModel(BaseModel):
class SystemFeatureModel(BaseModel): class SystemFeatureModel(BaseModel):
sso_enforced_for_signin: bool = False sso_enforced_for_signin: bool = False
sso_enforced_for_signin_protocol: str = "" sso_enforced_for_signin_protocol: str = ""
sso_enforced_for_web: bool = False
sso_enforced_for_web_protocol: str = ""
enable_web_sso_switch_component: bool = False
enable_email_code_login: bool = False enable_email_code_login: bool = False
enable_email_password_login: bool = True enable_email_password_login: bool = True
enable_social_oauth_login: bool = False enable_social_oauth_login: bool = False
@ -111,7 +113,6 @@ class FeatureService:
cls._fulfill_system_params_from_env(system_features) cls._fulfill_system_params_from_env(system_features)
if dify_config.ENTERPRISE_ENABLED: if dify_config.ENTERPRISE_ENABLED:
system_features.enable_web_sso_switch_component = True
system_features.branding.enabled = True system_features.branding.enabled = True
system_features.webapp_auth.enabled = True system_features.webapp_auth.enabled = True
cls._fulfill_params_from_enterprise(system_features) cls._fulfill_params_from_enterprise(system_features)
@ -180,21 +181,12 @@ class FeatureService:
features.model_load_balancing_enabled = billing_info["model_load_balancing_enabled"] features.model_load_balancing_enabled = billing_info["model_load_balancing_enabled"]
@classmethod @classmethod
def _fulfill_params_from_enterprise(cls, features): def _fulfill_params_from_enterprise(cls, features: SystemFeatureModel):
enterprise_info = EnterpriseService.get_info() enterprise_info = EnterpriseService.get_info()
if "SSOEnforcedForSignin" in enterprise_info: if "SSOEnforcedForSignin" in enterprise_info:
features.sso_enforced_for_signin = enterprise_info["SSOEnforcedForSignin"] features.sso_enforced_for_signin = enterprise_info["SSOEnforcedForSignin"]
if "SSOEnforcedForSigninProtocol" in enterprise_info:
features.sso_enforced_for_signin_protocol = enterprise_info["SSOEnforcedForSigninProtocol"]
if "SSOEnforcedForWeb" in enterprise_info:
features.sso_enforced_for_web = enterprise_info["SSOEnforcedForWeb"]
if "SSOEnforcedForWebProtocol" in enterprise_info:
features.sso_enforced_for_web_protocol = enterprise_info["SSOEnforcedForWebProtocol"]
if "EnableEmailCodeLogin" in enterprise_info: if "EnableEmailCodeLogin" in enterprise_info:
features.enable_email_code_login = enterprise_info["EnableEmailCodeLogin"] features.enable_email_code_login = enterprise_info["EnableEmailCodeLogin"]
@ -221,6 +213,9 @@ class FeatureService:
features.webapp_auth.allow_email_password_login = enterprise_info["WebAppAuth"].get( features.webapp_auth.allow_email_password_login = enterprise_info["WebAppAuth"].get(
"allowEmailPasswordLogin", False "allowEmailPasswordLogin", False
) )
features.webapp_auth.sso_config.protocol = enterprise_info.get(
"SSOEnforcedForSigninProtocol", ""
)
if "License" in enterprise_info: if "License" in enterprise_info:
license_info = enterprise_info["License"] license_info = enterprise_info["License"]