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 GitLab.com plans and features.
Restricting features scoped by namespaces or projects
GitLab.com 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.
- Add the feature symbol on
STARTER_FEATURES
,PREMIUM_FEATURES
, orULTIMATE_FEATURES
constants inee/app/models/gitlab_subscriptions/features.rb
. - Check using:
project.licensed_feature_available?(:feature_symbol)
or
group.licensed_feature_available?(:feature_symbol)
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.
- Add the feature symbol to
STARTER_FEATURES
,PREMIUM_FEATURES
orULTIMATE_FEATURES
constants inee/app/models/gitlab_subscriptions/features.rb
. - Add the same feature symbol to
GLOBAL_FEATURES
. - Check using:
License.feature_available?(:feature_symbol)
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
push_licensed_feature(:feature_symbol)
# or by project/namespace
push_licensed_feature(:feature_symbol, project)
end
Allow use of licensed EE features
To enable plans per namespace turn on the Allow use of licensed EE features
option from the settings page.
This will make licensed EE features available to projects only if the project namespace's plan includes the feature
or if the project is public. To enable it:
- If you are developing locally, follow the steps in simulate SaaS to make the option available.
- Select Admin > Settings > General > "Account and limit" and enable "Allow use of licensed EE features".