debian-mirror-gitlab/doc/development/licensed_feature_availability.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
2.6 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2021-03-11 19:13:27 +05:30
stage: Fulfillment
2022-06-21 17:19:12 +05:30
group: Provision
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2021-04-17 20:07:23 +05:30
# Licensed feature availability
2019-07-31 22:56:46 +05:30
2019-09-30 21:07:59 +05:30
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
2019-07-31 22:56:46 +05:30
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
2019-09-30 21:07:59 +05:30
feature such as [Related issues](../user/project/issues/related_issues.md) or
2020-10-24 23:57:45 +05:30
[Service Desk](../user/project/service_desk.md),
2019-07-31 22:56:46 +05:30
it should be restricted on namespace scope.
2022-05-07 20:08:51 +05:30
1. Add the feature symbol on `STARTER_FEATURES`, `PREMIUM_FEATURES`, or `ULTIMATE_FEATURES` constants in
`ee/app/models/gitlab_subscriptions/features.rb`.
2019-10-12 21:52:04 +05:30
1. Check using:
2019-07-31 22:56:46 +05:30
```ruby
2022-07-23 23:45:48 +05:30
project.licensed_feature_available?(:feature_symbol)
2019-07-31 22:56:46 +05:30
```
2022-07-23 23:45:48 +05:30
or
```ruby
group.licensed_feature_available?(:feature_symbol)
```
For projects, `licensed_feature_available` delegates to its associated `namespace`.
2019-07-31 22:56:46 +05:30
## Restricting global features (instance)
2020-11-24 15:15:51 +05:30
However, for features such as [Geo](../administration/geo/index.md) and
2022-01-26 12:08:38 +05:30
[Database Load Balancing](../administration/postgresql/database_load_balancing.md), which cannot be restricted
2021-02-22 17:27:13 +05:30
to only a subset of projects or namespaces, the check is made directly in
2019-07-31 22:56:46 +05:30
the instance license.
2022-05-07 20:08:51 +05:30
1. Add the feature symbol to `STARTER_FEATURES`, `PREMIUM_FEATURES` or `ULTIMATE_FEATURES` constants in
`ee/app/models/gitlab_subscriptions/features.rb`.
2021-04-17 20:07:23 +05:30
1. Add the same feature symbol to `GLOBAL_FEATURES`.
2019-10-12 21:52:04 +05:30
1. Check using:
2019-07-31 22:56:46 +05:30
```ruby
License.feature_available?(:feature_symbol)
```
2021-04-29 21:17:54 +05:30
## Restricting frontend features
To restrict frontend features based on the license, use `push_licensed_feature`.
The frontend can then access this via `this.glFeatures`:
```ruby
before_action do
push_licensed_feature(:feature_symbol)
# or by project/namespace
push_licensed_feature(:feature_symbol, project)
end
```
2022-08-13 15:12:31 +05:30
## 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:
1. If you are developing locally, follow the steps in [simulate SaaS](ee_features.md#act-as-saas) to make the option available.
1. Select Admin > Settings > General > "Account and limit" and enable "Allow use of licensed EE features".