diff --git a/server/auth.go b/server/auth.go index e27beeb..8a4ed4c 100644 --- a/server/auth.go +++ b/server/auth.go @@ -6,6 +6,7 @@ import ( "github.com/ProtonMail/go-proton-api" "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" ) func (s *Server) handlePostAuthInfo() gin.HandlerFunc { @@ -18,6 +19,7 @@ func (s *Server) handlePostAuthInfo() gin.HandlerFunc { info, err := s.b.NewAuthInfo(req.Username) if err != nil { + logrus.WithError(err).Errorf("User '%v' failed auth info", req.Username) _ = c.AbortWithError(http.StatusUnauthorized, err) return } @@ -48,6 +50,7 @@ func (s *Server) handlePostAuth() gin.HandlerFunc { auth, err := s.b.NewAuth(req.Username, clientEphemeral, clientProof, req.SRPSession) if err != nil { + logrus.WithError(err).Errorf("User '%v' not authorized", req.Username) _ = c.AbortWithError(http.StatusUnauthorized, err) return } diff --git a/server/backend/api_auth.go b/server/backend/api_auth.go index cb06844..0520376 100644 --- a/server/backend/api_auth.go +++ b/server/backend/api_auth.go @@ -7,6 +7,7 @@ import ( "github.com/ProtonMail/go-proton-api" "github.com/ProtonMail/go-srp" "github.com/google/uuid" + "github.com/sirupsen/logrus" ) func (b *Backend) NewAuthInfo(username string) (proton.AuthInfo, error) { @@ -14,12 +15,14 @@ func (b *Backend) NewAuthInfo(username string) (proton.AuthInfo, error) { return withAccName(b, username, func(acc *account) (proton.AuthInfo, error) { server, err := srp.NewServerFromSigned(modulus, acc.verifier, 2048) if err != nil { - return proton.AuthInfo{}, nil + logrus.WithError(err).Errorf("Failed to create SRP Server") + return proton.AuthInfo{}, fmt.Errorf("failed to create new srp server %w", err) } challenge, err := server.GenerateChallenge() if err != nil { - return proton.AuthInfo{}, nil + logrus.WithError(err).Errorf("Failed to generate srp challeng") + return proton.AuthInfo{}, fmt.Errorf("failed to generate srp challend %w", err) } session := uuid.NewString() @@ -42,6 +45,7 @@ func (b *Backend) NewAuth(username string, ephemeral, proof []byte, session stri return withAccName(b, username, func(acc *account) (proton.Auth, error) { server, ok := b.srp[session] if !ok { + logrus.Errorf("Session '%v' not found for user='%v'", session, username) return proton.Auth{}, fmt.Errorf("invalid session") } diff --git a/server/backend/quark.go b/server/backend/quark.go index cb835d8..1efed75 100644 --- a/server/backend/quark.go +++ b/server/backend/quark.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/ProtonMail/go-proton-api" + "github.com/sirupsen/logrus" ) func (s *Backend) RunQuarkCommand(command string, args ...string) (any, error) { @@ -77,6 +78,8 @@ func (s *Backend) quarkUserCreate(args ...string) (proton.User, error) { } } + logrus.Infof("User '%v' created with id=%v", *name, userID) + return s.GetUser(userID) }