move to zerolog

This commit is contained in:
Mikaël Cluseau
2024-01-20 16:41:54 +01:00
parent 5ab8b74041
commit 6bf1d1ccf2
18 changed files with 205 additions and 170 deletions

View File

@ -3,8 +3,8 @@ package main
import (
"bytes"
"errors"
"log"
"github.com/rs/zerolog/log"
"golang.org/x/crypto/ssh"
config "novit.tech/direktil/pkg/bootstrapconfig"
@ -23,7 +23,7 @@ func localAuth() bool {
}
if config.CheckPassword(auth.Password, sec) {
log.Printf("login with auth %q", auth.Name)
log.Info().Msgf("login with auth %q", auth.Name)
return true
}
}
@ -41,12 +41,12 @@ func sshCheckPubkey(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions,
allowedKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(auth.SSHKey))
if err != nil {
log.Printf("SSH pubkey for %q invalid: %v", auth.Name, auth.SSHKey)
log.Warn().Err(err).Str("user", auth.Name).Str("key", auth.SSHKey).Msg("SSH public key is invalid")
return nil, err
}
if bytes.Equal(allowedKey.Marshal(), keyBytes) {
log.Print("ssh: accepting public key for ", auth.Name)
log.Info().Str("user", auth.Name).Msg("ssh: accepting public key")
return &ssh.Permissions{
Extensions: map[string]string{
"pubkey-fp": ssh.FingerprintSHA256(key),