diff options
author | Codruț Constantin Gușoi <codrut.gusoi@gmail.com> | 2018-02-18 18:14:37 +0000 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-02-18 20:14:37 +0200 |
commit | 96c268c0fcc22604103f67821d66fef39944e80b (patch) | |
tree | fb5a97ff8557ae18dd22b227e52fcd811320eac3 /routers/install.go | |
parent | e59fe7c8d9eb8e49858cb2d59e8732f6058756ff (diff) | |
download | gitea-96c268c0fcc22604103f67821d66fef39944e80b.tar.gz gitea-96c268c0fcc22604103f67821d66fef39944e80b.zip |
Implements generator cli for secrets (#3531)
Signed-off-by: Codruț Constantin Gușoi <codrut.gusoi@gmail.com>
Diffstat (limited to 'routers/install.go')
-rw-r--r-- | routers/install.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/routers/install.go b/routers/install.go index c180d947fc..2a7ec93d21 100644 --- a/routers/install.go +++ b/routers/install.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/generate" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/user" @@ -275,7 +276,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { if form.LFSRootPath != "" { cfg.Section("server").Key("LFS_START_SERVER").SetValue("true") cfg.Section("server").Key("LFS_CONTENT_PATH").SetValue(form.LFSRootPath) - cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(base.GetRandomBytesAsBase64(32)) + var secretKey string + if secretKey, err = generate.NewLfsJwtSecret(); err != nil { + ctx.RenderWithErr(ctx.Tr("install.lfs_jwt_secret_failed", err), tplInstall, &form) + return + } + cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(secretKey) } else { cfg.Section("server").Key("LFS_START_SERVER").SetValue("false") } @@ -315,7 +321,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { cfg.Section("security").Key("INSTALL_LOCK").SetValue("true") var secretKey string - if secretKey, err = base.GetRandomString(10); err != nil { + if secretKey, err = generate.NewSecretKey(); err != nil { ctx.RenderWithErr(ctx.Tr("install.secret_key_failed", err), tplInstall, &form) return } |