1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 09:34:05 +08:00

add git.token

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-03-11 14:03:19 +08:00
parent 68cc665d54
commit 2bb2b168f8
2 changed files with 25 additions and 3 deletions

View File

@ -34,7 +34,7 @@ func _server_login(m *ice.Message) error {
if err != nil {
return err
}
if ls = strings.SplitN(string(data), ice.DF, 2); !aaa.UserLogin(m, ls[0], ls[1]) {
if ls = strings.SplitN(string(data), ice.DF, 2); m.Cmd("web.code.git.token", ls[0]).Append(TOKEN) != ls[1] && !aaa.UserLogin(m.Spawn(), ls[0], ls[1]) {
return fmt.Errorf("username or password error")
}
if aaa.UserRole(m, ls[0]) == aaa.VOID {
@ -137,7 +137,7 @@ func init() {
m.Warn(_server_repos(m, arg...), ice.ErrNotValid)
}}})
Index.MergeCommands(ice.Commands{
"inner": {Name: "inner repos branch commit path auto", Help: "服务器", Actions: ice.MergeActions(ice.Actions{}, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
"inner": {Name: "inner repos branch commit path auto token", Help: "服务器", Actions: ice.MergeActions(ice.Actions{}, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_REPOS); len(arg) == 0 {
} else if dir := path.Join(m.Option(nfs.DIR_ROOT), arg[0]); len(arg) == 1 {
} else if len(arg) == 2 {
@ -148,7 +148,7 @@ func init() {
_repos_cat(m, dir, arg[1], arg[2], kit.Select("", arg, 3))
}
}},
SERVER: {Name: "server repos branch commit path auto create import", Help: "代码源", Actions: ice.MergeActions(ice.Actions{
SERVER: {Name: "server repos branch commit path auto create import token", Help: "代码源", Actions: ice.MergeActions(ice.Actions{
mdb.CREATE: {Name: "create name*=demo", Hand: func(m *ice.Message, arg ...string) {
_repos_init(m, path.Join(ice.USR_LOCAL_REPOS, m.Option(mdb.NAME)))
}},
@ -184,6 +184,11 @@ func init() {
}
ctx.ProcessField(m, "", arg, arg...)
}},
TOKEN: {Hand: func(m *ice.Message, arg ...string) {
token := kit.Hashs("uniq")
m.Cmd(TOKEN, mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), TOKEN, token)
m.EchoScript(kit.Format("echo %s >> ~/.git-credentials", strings.Replace(m.Option(ice.MSG_USERHOST), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), token), 1)))
}},
}, gdb.EventAction(web.DREAM_INPUTS)), Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_REPOS); len(arg) == 0 {
m.Option(ice.MSG_USERROLE, aaa.TECH)

17
misc/git/token.go Normal file
View File

@ -0,0 +1,17 @@
package git
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/mdb"
)
const TOKEN = "token"
func init() {
Index.MergeCommands(ice.Commands{
TOKEN: {Name: "token username auto", Actions: ice.MergeActions(mdb.HashAction(
mdb.SHORT, aaa.USERNAME, mdb.EXPIRE, "720h", mdb.FIELD, "time,username,token",
))},
})
}