Implementation:Langgenius Dify Feature Types
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Frontend, TypeSystem, FeatureFlags |
| Last Updated | 2026-02-12 07:00 GMT |
Overview
TypeScript type definitions for system-level feature flags, SSO configuration, licensing, and plugin installation permissions.
Description
web/types/feature.ts defines the core types that control feature availability and system behavior in the Dify frontend. It exports:
Enums:
SSOProtocol: Authentication protocols -SAML,OIDC,OAuth2.LicenseStatus: License states -NONE,INACTIVE,ACTIVE,EXPIRING,EXPIRED,LOST.InstallationScope: Plugin installation permissions -ALL,NONE,OFFICIAL_ONLY,OFFICIAL_AND_PARTNER.
Types:
SystemFeatures: The primary feature configuration type containing:trial_models- Available trial model providersplugin_installation_permission- Scope and marketplace restrictions- SSO enforcement flags for both sign-in and web access, with protocol settings
- Authentication toggles:
enable_email_code_login,enable_email_password_login,enable_social_oauth_login,enable_change_email - Workspace settings:
is_allow_create_workspace,is_allow_register license- Status and expiration datebranding- Custom logos, favicon, and application titlewebapp_auth- Web app authentication settings including SSOenable_marketplace,enable_trial_app,enable_explore_banner
Default values:
defaultSystemFeatures: A complete default configuration constant with all features disabled, empty branding,LicenseStatus.NONE, and empty arrays. Used as fallback before the server configuration is loaded.
Usage
Import SystemFeatures to type feature flag state and defaultSystemFeatures as the initial value before the system configuration API response is received.
Code Reference
Source Location
- Repository: Langgenius_Dify
- File: web/types/feature.ts
- Lines: 1-109
Signature
export enum SSOProtocol {
SAML = 'saml',
OIDC = 'oidc',
OAuth2 = 'oauth2',
}
export enum LicenseStatus {
NONE = 'none',
INACTIVE = 'inactive',
ACTIVE = 'active',
EXPIRING = 'expiring',
EXPIRED = 'expired',
LOST = 'lost',
}
export enum InstallationScope {
ALL = 'all',
NONE = 'none',
OFFICIAL_ONLY = 'official_only',
OFFICIAL_AND_PARTNER = 'official_and_specific_partners',
}
export type SystemFeatures = {
trial_models: ModelProviderQuotaGetPaid[]
plugin_installation_permission: {
plugin_installation_scope: InstallationScope
restrict_to_marketplace_only: boolean
}
sso_enforced_for_signin: boolean
sso_enforced_for_signin_protocol: SSOProtocol | ''
enable_marketplace: boolean
license: { status: LicenseStatus; expired_at: string | null }
branding: { enabled: boolean; login_page_logo: string; workspace_logo: string; favicon: string; application_title: string }
webapp_auth: { enabled: boolean; allow_sso: boolean; /* ... */ }
// ...additional flags
}
export const defaultSystemFeatures: SystemFeatures
Import
import type { SystemFeatures } from '@/types/feature'
import { defaultSystemFeatures, LicenseStatus, SSOProtocol, InstallationScope } from '@/types/feature'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A | N/A | N/A | Type and constant definitions; no runtime inputs. |
Outputs
| Name | Type | Description |
|---|---|---|
| SSOProtocol | enum | Supported SSO authentication protocols |
| LicenseStatus | enum | Possible license states |
| InstallationScope | enum | Plugin installation permission levels |
| SystemFeatures | type | Complete system feature flag configuration |
| defaultSystemFeatures | const | Default feature flags with all features disabled |
Usage Examples
Checking License Status
import type { SystemFeatures } from '@/types/feature'
import { LicenseStatus } from '@/types/feature'
function isLicenseValid(features: SystemFeatures): boolean {
return features.license.status === LicenseStatus.ACTIVE
|| features.license.status === LicenseStatus.EXPIRING
}
Initializing Feature State
import { defaultSystemFeatures } from '@/types/feature'
const [features, setFeatures] = useState(defaultSystemFeatures)
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment