diff options
author | Paweł Bogusławski <pawel.boguslawski@ib.pl> | 2020-12-21 15:39:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-21 15:39:41 +0100 |
commit | 839daa85aaba5172b3dd2b3f882aa9639a09f13a (patch) | |
tree | cc99ed17087fd3b3b44cdb650efe16e6f0394e55 /routers/api/v1 | |
parent | 3a500cf8c4b7892e13cb506af6fe3ab5c1c2faff (diff) | |
download | gitea-839daa85aaba5172b3dd2b3f882aa9639a09f13a.tar.gz gitea-839daa85aaba5172b3dd2b3f882aa9639a09f13a.zip |
Added option to disable migrations (#13114)
* Added option to disable migrations
This patch introduces DISABLE_MIGRATIONS parameter in [repository]
section of app.ini (by default set to false). If set to true
it blocks access to repository migration feature.
This mod hides also local repo import option in user editor if
local repo importing or migrations is disabled.
* Alter Example config
DISABLE_MIGRATIONS set to false in example config to
match its default value.
* HTTP error 403 instead of 500 on denied access to migration
* Parameter DISABLE_MIGRATIONS exposed via API
Fixes: 04b04cf854bcb3ed7659442bcf79822bdebe29e9
Author-Change-Id: IB#1105130
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/repo/migrate.go | 5 | ||||
-rw-r--r-- | routers/api/v1/settings/settings.go | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go index 511e91f94e..ab480c29aa 100644 --- a/routers/api/v1/repo/migrate.go +++ b/routers/api/v1/repo/migrate.go @@ -119,6 +119,11 @@ func Migrate(ctx *context.APIContext, form api.MigrateRepoOptions) { return } + if setting.Repository.DisableMigrations { + ctx.Error(http.StatusForbidden, "MigrationsGlobalDisabled", fmt.Errorf("the site administrator has disabled migrations")) + return + } + var opts = migrations.MigrateOptions{ CloneAddr: remoteAddr, RepoName: form.RepoName, diff --git a/routers/api/v1/settings/settings.go b/routers/api/v1/settings/settings.go index c94a3141e2..6095988404 100644 --- a/routers/api/v1/settings/settings.go +++ b/routers/api/v1/settings/settings.go @@ -57,8 +57,9 @@ func GetGeneralRepoSettings(ctx *context.APIContext) { // "200": // "$ref": "#/responses/GeneralRepoSettings" ctx.JSON(http.StatusOK, api.GeneralRepoSettings{ - MirrorsDisabled: setting.Repository.DisableMirrors, - HTTPGitDisabled: setting.Repository.DisableHTTPGit, + MirrorsDisabled: setting.Repository.DisableMirrors, + HTTPGitDisabled: setting.Repository.DisableHTTPGit, + MigrationsDisabled: setting.Repository.DisableMigrations, }) } |