From 404191b9675df8589317b1964497d3053fb5ec21 Mon Sep 17 00:00:00 2001 From: MalinAhlberg Date: Mon, 25 Nov 2024 14:44:47 +0100 Subject: [PATCH] [auth] refactor: use panic to avoid fatalf, clean up logs --- sda/cmd/auth/main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sda/cmd/auth/main.go b/sda/cmd/auth/main.go index 378fc6a65..b2b8c17ed 100644 --- a/sda/cmd/auth/main.go +++ b/sda/cmd/auth/main.go @@ -266,7 +266,7 @@ func (auth AuthHandler) elixirLogin(ctx iris.Context) *OIDCData { } err = auth.Config.DB.UpdateUserInfo(idStruct.User, idStruct.Profile, idStruct.Email, idStruct.EdupersonEntitlement) if err != nil { - log.Warnf("Could not log user info for %s (%s, %s)", idStruct.User, idStruct.Name, idStruct.Email) + log.Warn("Could not log user info.") } if auth.Config.ResignJwt { @@ -412,6 +412,7 @@ func main() { log.Error("database schema v14 is required") panic(err) } + defer authHandler.Config.DB.Close() app.RegisterView(iris.HTML(authHandler.htmlDir, ".html")) app.HandleDir("/public", iris.Dir(authHandler.staticDir)) @@ -432,14 +433,12 @@ func main() { authHandler.pubKey, err = readPublicKeyFile(authHandler.Config.PublicFile) if err != nil { - log.Fatalf("Failed to read public key: %s", err.Error()) + log.Panicf("Failed to read public key: %s", err.Error()) } // Endpoint for client login info app.Get("/info", authHandler.getInfo) - defer authHandler.Config.DB.Close() // needs to be after Fatalf - app.UseGlobal(globalHeaders) if config.Server.Cert != "" && config.Server.Key != "" {