diff options
| author | Max Resnick <max@ofmax.li> | 2023-04-02 08:52:52 -0700 |
|---|---|---|
| committer | Max Resnick <max@ofmax.li> | 2023-05-26 09:47:59 -0700 |
| commit | 480ce38f8c01de00adf6de651b8c2c57cd2148be (patch) | |
| tree | 85bd66986cb3f0ad501549e46e649073775e8077 /cmd | |
| parent | 9e04be2ca3d8980ebc8ec791d005ba77382fb1fa (diff) | |
| download | go-git-server-480ce38f8c01de00adf6de651b8c2c57cd2148be.tar.gz | |
Adds a lot of tests adds middleware hook
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/main.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/cmd/main.go b/cmd/main.go index f2f1c63..bf3697d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -12,14 +12,15 @@ import ( ) var ( - reposDir = flag.String("r", "./repos", "Directory containing git repositories") - backendCommand = flag.String("c", "git http-backend", "CGI binary to execute") - addr = flag.String("l", ":8080", "Address/port to listen on") - modelPath = flag.String("m", "./auth_model.ini", "Authentication model") - policyPath = flag.String("p", "./policy.csv", "auth policy") - serverConfig = flag.String("s", "./gitserver.yaml", "serverconfig path") - newToken = flag.Bool("t", false, "make a new token") - updatePolicies = flag.Bool("u", false, "update policies") + reposDir = flag.String("r", "./repos", "Directory containing git repositories") + mgmtRepo = flag.Bool("a", true, "mgmt repo used for configuration") + backendCommand = flag.String("c", "git http-backend", "CGI binary to execute") + addr = flag.String("l", ":8080", "Address/port to listen on") + modelPath = flag.String("m", "./auth_model.ini", "Authentication model") + policyPath = flag.String("p", "./policy.csv", "auth policy") + serverConfigPath = flag.String("s", "/gitserver.yaml", "serverconfig path") + newToken = flag.Bool("t", false, "make a new token") + updatePolicies = flag.Bool("u", false, "update policies") ) func main() { @@ -32,7 +33,7 @@ func main() { fmt.Printf("token: %s\nhash: %s\n", token, hash) return } - adminSvc := admin.NewService(*modelPath, *policyPath, *serverConfig) + adminSvc := admin.NewService(*modelPath, *policyPath, *serverConfigPath, *reposDir, *mgmtRepo) adminSvc.InitServer() tokens := authz.NewTokenMap() err := tokens.LoadTokensFromFile("./tokens.csv") @@ -42,6 +43,7 @@ func main() { router := http.NewServeMux() // TODO we don't want to use a global // de-reference args + router.Handle("/mgmt/", admin.AdminHooks(adminSvc, git.GitHttpBackendHandler(*reposDir, *backendCommand))) router.Handle("/", git.GitHttpBackendHandler(*reposDir, *backendCommand)) mux := authz.Authentication(tokens, authz.Authorization(adminSvc, router)) log.Fatal(http.ListenAndServe(":8080", mux)) |