aboutsummaryrefslogtreecommitdiff
path: root/cmd/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/main.go')
-rw-r--r--cmd/main.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/cmd/main.go b/cmd/main.go
index b679e51..bda8bf6 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -66,18 +66,33 @@ func main() {
if err := adminSvc.InitServer(); err != nil {
slog.Error("error initializing server", "msg", err)
}
- tokens := authz.NewTokenMap()
- err = tokens.LoadTokensFromFile(tokenFilePath)
+ // Load authentication tokens and identity mappings
+ tokens := authz.NewSafeTokenMap()
+ identities := authz.NewIdentityMap()
+
+ // Load tokens from CSV file
+ tokenMap, identityMap, err := authz.LoadTokensFromFile(tokenFilePath)
if err != nil {
- slog.Error("error generating token", slog.Any("error", err))
+ slog.Error("error loading tokens", slog.Any("error", err))
os.Exit(1)
}
+
+ // Update the token map with loaded values
+ for id, hash := range tokenMap {
+ tokens.Set(id, hash)
+ }
+
+ // Copy identity mappings
+ for id, name := range identityMap.IDToName {
+ identities.Register(id, name)
+ }
+
router := http.NewServeMux()
// TODO we don't want to use a global
// de-reference args
router.Handle("/mgmt/", admin.Hooks(adminSvc, git.GitHttpBackendHandler(reposDir, backendCommand)))
router.Handle("/", git.GitHttpBackendHandler(reposDir, backendCommand))
- mux := authz.Authentication(tokens, authz.Authorization(adminSvc, router))
+ mux := authz.Authentication(tokens, identities, authz.Authorization(adminSvc, router))
server := &http.Server{
Addr: addr,
ReadHeaderTimeout: 5 * time.Second,