mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
Add Chef package registry (#22554)
This PR implements a [Chef registry](https://chef.io/) to manage cookbooks. This package type was a bit complicated because Chef uses RSA signed requests as authentication with the registry.   Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@ -5,10 +5,14 @@ package setting
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
chef_module "code.gitea.io/gitea/modules/packages/chef"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
shared "code.gitea.io/gitea/routers/web/shared/packages"
|
||||
)
|
||||
|
||||
@ -95,3 +99,21 @@ func RebuildCargoIndex(ctx *context.Context) {
|
||||
|
||||
ctx.Redirect(setting.AppSubURL + "/user/settings/packages")
|
||||
}
|
||||
|
||||
func RegenerateChefKeyPair(ctx *context.Context) {
|
||||
priv, pub, err := util.GenerateKeyPair(chef_module.KeyBits)
|
||||
if err != nil {
|
||||
ctx.ServerError("GenerateKeyPair", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := user_model.SetUserSetting(ctx.Doer.ID, chef_module.SettingPublicPem, pub); err != nil {
|
||||
ctx.ServerError("SetUserSetting", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.ServeContent(strings.NewReader(priv), &context.ServeHeaderOptions{
|
||||
ContentType: "application/x-pem-file",
|
||||
Filename: ctx.Doer.Name + ".priv",
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user