aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Resnick <max@ofmax.li>2024-08-24 17:09:03 -0700
committerMax Resnick <max@ofmax.li>2024-08-24 17:09:03 -0700
commit71ba0cd9b988813da1b5c7101f8bf5918df0f795 (patch)
tree5fb2e195a24a91dcd5997d8f3dfa346b8e73c998
parent6889411b014b39a440b7cbe52b482b28415ed829 (diff)
downloadgo-git-server-71ba0cd9b988813da1b5c7101f8bf5918df0f795.tar.gz
chore: add env var for log level, fix bug, cleanup push target
Diffstat (limited to '')
-rw-r--r--cmd/main.go6
-rw-r--r--internal/admin/service.go1
-rw-r--r--internal/authz/middleware.go2
-rw-r--r--justfile3
4 files changed, 10 insertions, 2 deletions
diff --git a/cmd/main.go b/cmd/main.go
index c6b9854..96c3e93 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -87,8 +87,12 @@ func main() {
}
func init() {
+ logLevel, ok := os.LookupEnv("GO_GIT_SERVER_LOG_LEVEL")
+ if !ok {
+ logLevel = "INFO"
+ }
flag.StringVar(&backendCommand, "c", "git http-backend", "CGI binary to execute")
- flag.StringVar(&loggingLevel, "e", "INFO", "set log level")
+ flag.StringVar(&loggingLevel, "e", logLevel, "set log level")
flag.StringVar(&addr, "l", ":8080", "Address/port to listen on")
flag.StringVar(&modelPath, "m", "./auth_model.ini", "casbin authentication model")
flag.StringVar(&policyPath, "p", "./policy.csv", "casbin auth policy")
diff --git a/internal/admin/service.go b/internal/admin/service.go
index 4f955da..d60a072 100644
--- a/internal/admin/service.go
+++ b/internal/admin/service.go
@@ -65,6 +65,7 @@ func (s *Servicer) InitServer() error {
return fmt.Errorf("cloudn't load policy %w", err)
}
slog.Info("policy loaded")
+ slog.Debug("init server", "repoDir", s.reposDir)
if err := s.Conf.ConfigureRepos(); err != nil {
return fmt.Errorf("couldn't configure repos %w", err)
}
diff --git a/internal/authz/middleware.go b/internal/authz/middleware.go
index 3ba95ad..31f7bf3 100644
--- a/internal/authz/middleware.go
+++ b/internal/authz/middleware.go
@@ -27,6 +27,7 @@ func Authentication(authMap TokenMap, next http.Handler) http.Handler {
u = "anon"
ctx := context.WithValue(req.Context(), AuthzUrnKey, u)
next.ServeHTTP(rw, req.WithContext(ctx))
+ return
}
urn := fmt.Sprintf("uid:%s", u)
hash, ok := authMap[urn]
@@ -76,6 +77,7 @@ func Authorization(adminSvc *admin.Servicer, next http.Handler) http.Handler {
slog.Info("Not Authorized", "urn", urn, "repo", repo)
http.Error(rw, "Access denied", http.StatusForbidden)
return
+
}
slog.Debug("Access Attempt", "action", action, "repo", repo)
next.ServeHTTP(rw, req.WithContext(ctx))
diff --git a/justfile b/justfile
index c673c6a..2c7b066 100644
--- a/justfile
+++ b/justfile
@@ -76,7 +76,8 @@ build version: test builddir
push:
new_ver=$(cat {{ NEW_VERSION }}); \
- just docker-push git-push $new_ver
+ just docker-push $new_ver; \
+ just git-push $new_ver
@echo "pushed to all endpoints"
docker-push tag="latest" registry="public.ecr.aws/s0f9o2k5":