Add npm_package_requests_forwarding to ApplicationSetting
What does this MR do?
Add a new boolean setting to ApplicationSetting
: npm_package_requests_forwarding
. This setting is also made available in the Application settings API.
This setting will be used (in a future MR) to control npm package requests forwarding. In short, when GitLab receives a requests for the npm package X
(usually done by npm
or yarn
) and this package is not found in the npm repository (https://docs.gitlab.com/ee/user/packages/npm_registry/index.html), the request is forwarded to npmjs.org
.
Basically, the forwarding will happen like this (implemented in a future MR):
-
npm
asks for@acme/foobar
package on the GitLab npm api. - the api doesn't find this package and forwards the request to
npmjs.org
. If successful, the response is handled back tonpm
.
Note that due to how the npm repository is configured (the registry url in the .npmrc
file points to the npm api at the instance level), this setting has to be applied at the instance level. That's why this MR adds a new attribute to the ApplicationSetting
model.
This MR is part of the implementation for the following issue: #55344 (closed).
The future MRs are:
- one backend MR to implement the requests forwarding and add the documentation.
- one frontend MR to add the corresponding button in the admin UI for this
npm_package_requests_forwarding
flag.
Screenshots
n/a
## DB migration:
$ rails db:migrate
== 20200213155311 AddNpmPackageRequestsForwardingToApplicationSettings: migrating
-- transaction_open?()
-> 0.0000s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- transaction()
-- add_column(:application_settings, :npm_package_requests_forwarding, :boolean, {:default=>nil})
-> 0.0031s
-- change_column_default(:application_settings, :npm_package_requests_forwarding, false)
-> 0.0219s
-> 0.0265s
-- columns(:application_settings)
-> 0.0203s
-- transaction_open?()
-> 0.0000s
-- exec_query("SELECT COUNT(*) AS count FROM \"application_settings\"")
-> 0.0008s
-- exec_query("SELECT \"application_settings\".\"id\" FROM \"application_settings\" ORDER BY \"application_settings\".\"id\" ASC LIMIT 1")
-> 0.0006s
-- exec_query("SELECT \"application_settings\".\"id\" FROM \"application_settings\" WHERE \"application_settings\".\"id\" >= 1 ORDER BY \"application_settings\".\"id\" ASC LIMIT 1 OFFSET 1")
-> 0.0005s
-- execute("UPDATE \"application_settings\" SET \"npm_package_requests_forwarding\" = FALSE WHERE \"application_settings\".\"id\" >= 1")
-> 0.0017s
-- change_column_null(:application_settings, :npm_package_requests_forwarding, false)
-> 0.0020s
-- execute("RESET ALL")
-> 0.0005s
== 20200213155311 AddNpmPackageRequestsForwardingToApplicationSettings: migrated (0.0540s)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team