From 480ce38f8c01de00adf6de651b8c2c57cd2148be Mon Sep 17 00:00:00 2001 From: Max Resnick Date: Sun, 2 Apr 2023 08:52:52 -0700 Subject: Adds a lot of tests adds middleware hook --- cmd/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'cmd') 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)) -- cgit v1.2.3