Skip to content

Commit

Permalink
[auth] refactor: use panic to avoid fatalf, clean up logs
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed Nov 29, 2024
1 parent dc8fbf3 commit 404191b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sda/cmd/auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand All @@ -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 != "" {
Expand Down

0 comments on commit 404191b

Please sign in to comment.