Licensed feature availability

As of GitLab 9.4, we've been supporting a simplified version of licensed feature availability checks via ee/app/models/license.rb, both for on-premise or plans and features.

Restricting features scoped by namespaces or projects plans are persisted on user groups and namespaces, therefore, if you're adding a feature such as Related issues or Service Desk, it should be restricted on namespace scope.

  1. Add the feature symbol on STARTER_FEATURES, PREMIUM_FEATURES, or ULTIMATE_FEATURES constants in ee/app/models/gitlab_subscriptions/features.rb.
  2. Check using:



For projects, licensed_feature_available delegates to its associated namespace.

Restricting global features (instance)

However, for features such as Geo and Database Load Balancing, which cannot be restricted to only a subset of projects or namespaces, the check is made directly in the instance license.

  1. Add the feature symbol to STARTER_FEATURES, PREMIUM_FEATURES or ULTIMATE_FEATURES constants in ee/app/models/gitlab_subscriptions/features.rb.
  2. Add the same feature symbol to GLOBAL_FEATURES.
  3. Check using:

Restricting frontend features

To restrict frontend features based on the license, use push_licensed_feature. The frontend can then access this via this.glFeatures:

before_action do
  # or by project/namespace
  push_licensed_feature(:feature_symbol, project)